A regular expression match

To add comments, please log in or register
habboubih
118
habboubih  

Hello,

 I am looking for a function that acts like the preg_match in PHP that performs a regular expression match.

 

For example, if I have a string in MQL4 that contains the following HTML code

 

<td id="pair_name_0" class="first left bold noWrap">Fibonacci<td id="open_0">1.2532</td><td id="high_0">1.2535</td><td id="low_0">1.2538</td><td class="bold" id="low_0">1.2541</td><td id="low_0">1.2544</td>

 I want the function to search the string for the values between the tags <td id="open_0"> and </td>, <td id="high_0"> and </td>, <td id="low_0"> and </td> ... etc... and saves them in a new string or int.

Stuart Browne
8791
Stuart Browne  

Hiya

I think you'd have to do it with a combination of StringSplit, StingFind, StringSubstr etc. There's probably a bunch of string scripts in the codebase, have you had a search through there?

String Functions - MQL4 Documentation
  • docs.mql4.com
String Functions - MQL4 Documentation
habboubih
118
habboubih  
Filter:

Hiya

I think you'd have to do it with a combination of StringSplit, StingFind, StringSubstr etc. There's probably a bunch of string scripts in the codebase, have you had a search through there?

Yes sir I have read this but I can't get a simple way to do this. I am trying to create a function that does that but could not succeed.
Stanislav Korotky
31616
Stanislav Korotky  
habboubih:
Yes sir I have read this but I can't get a simple way to do this. I am trying to create a function that does that but could not succeed.
Try to look at this article - it contains an HTML parser class.
Arturo Lopez Perez
254540
Arturo Lopez Perez  

You can import any regular expression library written in C into your EA. There are many available.

http://slre.sourceforge.net/

SLRE - Super Light Regular Expression library
  • slre.sourceforge.net
SLRE (Super Light Regular Expression) library is a subset of Perl RE implemented in ANSI C.
To add comments, please log in or register