Hello,
I am very poor at Regular Expression. I tried for a few hours and still could not get the answer. My problem is:
The following is a single line:
<td bgcolor="#CCCCCC" align="center" width="53"><font face="Verdana, Arial, Helvetica, sans-serif" size="2">10.94</font></td>
I wish to get the 10.94 value by using the get MatchText(myVar, ".......", ) but no luck. Could someone please help me to get the answer.
Thanks and best regards
Need help with "get MatchText" to get a value of a
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Need help with "get MatchText" to get a value of a
Alex
Nice to meet all of you.
Nice to meet all of you.
-
- Posts: 179
- Joined: Sat Apr 08, 2006 11:08 pm
- Contact:
Re: Need help with "get MatchText" to get a value
Alex, I can't help you with regular expressions, but bear in mind that Revolutions own chunk expressions can be very powerful.
In the case you've given, you could do this:
assume the line is in a variable <tLine>
This is just off the top of my head, so is not necessarily the best possible way, but will work for the example given.
Best,
Mark
In the case you've given, you could do this:
assume the line is in a variable <tLine>
Code: Select all
function extractValue tLine
replace ">" with ">" & cr in tLine
replace "<" with cr in tLine
filter tLine without empty
filter tLine without "*>"
return tLine
end extractValue
Best,
Mark
I see two other ways of achieving the same result, that might be better.
First, as this happens to be HTML, you could use a trick by setting the HTMLText of a field like this:
And here is for the regular expression you were looking for... looks like a sort of big smiley ^^ They can be hard to learn at first, but it's really all hardcore logic.
First, as this happens to be HTML, you could use a trick by setting the HTMLText of a field like this:
Code: Select all
function extractValue tLine
set the htmltext of field "tempField" to tLine
return field "tempField"
end extractValue
Code: Select all
function extractValue tLine
matchText(tLine,">([^<>]+)<",tempVar)
return tempVar
end extractValue
Hi,
Thanks for your great help. All methods are really very interesting and I learn a lot.
Actually I am always using itemDel, a easier method and can achieve expected result in many cases. However this is quite "boring" and I really wish to learn other ways. For example:
put field "htmlCode" into tData
set the itemDel to ">"
put item 3 of tData into tData
set the itemDel to "<"
put item 1 of tData into field "Result"
Thanks and best regards
Thanks for your great help. All methods are really very interesting and I learn a lot.
Actually I am always using itemDel, a easier method and can achieve expected result in many cases. However this is quite "boring" and I really wish to learn other ways. For example:
put field "htmlCode" into tData
set the itemDel to ">"
put item 3 of tData into tData
set the itemDel to "<"
put item 1 of tData into field "Result"
Thanks and best regards
Alex
Nice to meet all of you.
Nice to meet all of you.