12-09-2015 05:31 AM
hello. Im having some issues with this.
I have a very long multi line string with a lot of numbers in it. The string is from a HTML so contains a lot of junk as well.
I want to match the expression <td class="s0" dir="ltr">[0-9].[0-9]</td>
[0-9].[0-9] being either a 2 digit or 3 digit number with 2 decimal places (100.11 or 99.88) and then take these numbers and add them to an array.
i tried matching the expression <td class="s0" dir="ltr">[0-9].[0-9]</td> but tht just returns <td class="s0" dir="ltr"> </td> from the whole match node.
am i using this right and if so why is it not pulling up the numbers.
12-09-2015 05:42 AM
12-09-2015 08:04 AM
Scan from String and Format into String are two of my favorite String functions. Expanding slightly on Gerd's example,
Bob Schor
12-09-2015 08:11 AM
Hi Bob,
when parsing HTML files "manually" it seems less error prone (IMHO) to search for some "markers" first and then use ScanFromString on the data just following those markers - that's the reason to use MatchPattern first, followed by ScanFromString…
12-09-2015 08:46 AM
@AceScottie wrote:
hello. Im having some issues with this.
I have a very long multi line string with a lot of numbers in it. The string is from a HTML so contains a lot of junk as well.
I want to match the expression <td class="s0" dir="ltr">[0-9].[0-9]</td>
[0-9].[0-9] being either a 2 digit or 3 digit number with 2 decimal places (100.11 or 99.88) and then take these numbers and add them to an array.
i tried matching the expression <td class="s0" dir="ltr">[0-9].[0-9]</td> but tht just returns <td class="s0" dir="ltr"> </td> from the whole match node.
am i using this right and if so why is it not pulling up the numbers.
Can you provide us with a typical multi line string and the expected match?
Ben64
note: in your regex the dot will match any character not just the decimal point, to litterally match the decimal point you need to preced it with the escape character \.
12-09-2015 09:00 AM
12-09-2015 10:42 AM
I posted a snippet that uses Match Pattern to find the stuff between HTML tags here - http://forums.ni.com/t5/BreakPoint/Regular-Expressions-Board/m-p/1193689#M13534
The regex was <(\w*)>(.*)</\1>
Right away, I see that your regex looks for exactly one digit after the >, then one of anything then exactly one digit before the next <. You need to specify repeating character classes and escape the decimal point.