Forex Stock Exchange Forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Forex Stock Exchange Forum

Forum About Trading on Forex,Stock,Binary Options, CryptoCurrency and NFTs


You are not connected. Please login or register

MT5 Class: SymbolNameExtractor for Removing Non-Alphabetic Characters"

Go down  Message [Page 1 of 1]

gandra

gandra
Global Moderator

Explanation of SymbolNameExtractor Class


The SymbolNameExtractor class is designed to process symbol names and extract only the alphabetic characters from them. It is especially useful when you need to clean up symbol names by removing special characters and numbers, keeping only the letters. This can be useful for creating cleaner and more consistent table names(SQLite) or identifiers in your applications.

Class Details
  • Constructor: Initializes a new instance of the SymbolNameExtractor class.
  • Method: ExtractLettersOnly
  • Purpose: To extract only the alphabetic characters (both uppercase and lowercase) from a given symbol name.
  • Parameters: symbol_name (string): The original name of the symbol, which may contain letters, numbers, and special characters.
  • Returns: A string containing only the alphabetic characters from the symbol_name.



How It Works:
  1. Initialize an empty string called result to store the cleaned name.
  2. Loop through each character in the symbol_name.
  3. Check if the character is a letter ('A' to 'Z' or 'a' to 'z').
  4. Append the letter to the result if it meets the criteria.
  5. Return the cleaned string containing only the letters.

SymbolNameExtractor class code snippet for MetaTrader 5 (MT5) in MQL5::

Here's a simple example showing how to use the SymbolNameExtractor class to clean up a symbol name.
Example Usage:

Summary
  • Purpose: To clean symbol names by removing non-letter characters.
  • Usage: Create an instance of the class and call ExtractLettersOnly with the symbol name you want to clean.


Feel free to use and adapt this class for your projects where you must handle and clean symbol names!



If you visit the first link, you can buy the best gold trading robots in the world!


  • Telegram Channel: [You must be registered and logged in to see this link.]
  • Telegram Chat Group: [You must be registered and logged in to see this link.]
  • Facebook Channel: [You must be registered and logged in to see this link.]
  • YouTube  "Algorithmic Trading System" : @algorithmictradingsystems
https://www.tradingview.com/u/DraganDrenjanin/ https://www.mql5.com/en/users/drgandra/seller#products

Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum