Miguel Posted March 8, 2008 Share Posted March 8, 2008 Could anyone give me some help to solve my problem (i´m portuguese, sorry my bad english)I have this html code: ...<td id=l4 title=125>23930/320000</td><td id=l3 title=100>38279/320000</td><td id=l2 title=100>98610/320000</td><td><td id=l1 title=-9917>161353/245000</td>...and i want to extract the bold number. The number "-9917" is variable as also the number "245000"I have read lots of topics in the forum and read the StringRegExp help file but i can´t get there... Link to comment Share on other sites More sharing options...
The Kandie Man Posted March 8, 2008 Share Posted March 8, 2008 You want something like this? #include <Array.au3> $sText = "<td id=l4 title=125>23930/320000</td>" & @CRLF & _ "<td id=l3 title=100>38279/320000</td>" & @CRLF & _ "<td id=l2 title=100>98610/320000</td><td>" & @CRLF & _ "<td id=l1 title=-9917>161353/245000</td>" $as_Matches = StringRegExp($sText,"(?i)title=-9917>(\d*?)/24500",3) _ArrayDisplay($as_Matches) - The Kandie Man ;-) "So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire Link to comment Share on other sites More sharing options...
Miguel Posted March 8, 2008 Author Share Posted March 8, 2008 You want something like this? #include <Array.au3> $sText = "<td id=l4 title=125>23930/320000</td>" & @CRLF & _ "<td id=l3 title=100>38279/320000</td>" & @CRLF & _ "<td id=l2 title=100>98610/320000</td><td>" & @CRLF & _ "<td id=l1 title=-9917>161353/245000</td>" $as_Matches = StringRegExp($sText,"(?i)title=-9917>(\d*?)/24500",3) _ArrayDisplay($as_Matches) - The Kandie Man ;-) Yes, but that wouldnt work, because de number -9917 and 245000 are variables. I want to extract the number in the line wich begins with "td id=l1" and is between ">" and "/". thanks in advance. Link to comment Share on other sites More sharing options...
Xenobiologist Posted March 8, 2008 Share Posted March 8, 2008 Does this pattern match? (?<=<.*id=.1.*?>).*?(?=\/) Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Miguel Posted March 8, 2008 Author Share Posted March 8, 2008 Does this pattern match? (?<=<.*id=.1.*?>).*?(?=\/)MegaI have tested it and it didn´t work. Sorry but i cant tell you why it didn´t work (I think this is too much for me)The variables are at bold, the rest is always the same. Tell me if this information isn´t enough.<td id=l1 title=-9917>161353/245000</td> Link to comment Share on other sites More sharing options...
The Kandie Man Posted March 8, 2008 Share Posted March 8, 2008 Miguel, give a list of about five lines that should match the expression and bold the part that you want returned. Make sure you change things so we know what things can change. Keep the things constant that don't change so we can create a regular expression that matches based on the things that are always the same.- The Kandie Man ;-) "So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire Link to comment Share on other sites More sharing options...
Miguel Posted March 8, 2008 Author Share Posted March 8, 2008 Miguel, give a list of about five lines that should match the expression and bold the part that you want returned. Make sure you change things so we know what things can change. Keep the things constant that don't change so we can create a regular expression that matches based on the things that are always the same.- The Kandie Man ;-)here it goes,<td id=l1 title=-9917>161353/245000</td><td id=l1 title=5467>99353/250000</td><td id=l1 title=-10517>13045/260000</td><td id=l1 title=-9756>163053/271000</td><td id=l1 title=-8520>151530/285000</td>thanks for your help. Link to comment Share on other sites More sharing options...
JusGellin Posted March 8, 2008 Share Posted March 8, 2008 Try this: #include <Array.au3> $sText = "<td id=l1 title=-9917>161353/245000</td>" & @CRLF & _ "<td id=l1 title=5467>99353/250000</td>" & @CRLF & _ "<td id=l1 title=-10517>13045/260000</td>" & @CRLF & _ "<td id=l1 title=-9756>163053/271000</td>" & @CRLF & _ "<td id=l1 title=-8520>151530/285000</td>" $as_Matches = StringRegExp($sText, ">(.*?)/", 3) _ArrayDisplay($as_Matches) Link to comment Share on other sites More sharing options...
Xenobiologist Posted March 8, 2008 Share Posted March 8, 2008 Hi, if the ID = 1 stil counts Global $a[7] $a[0] = "<td id=l1 title=-9917>161353/245000</td>" $a[1] = "<td id=l1 title=5467>99353/250000</td>" $a[2] = "<td id=l1 title=-10517>13045/260000</td>" $a[3] = "<td id=l1 title=-9756>163053/271000</td>" $a[4] = "<td id=l1 title=-8520>151530/285000</td>" $a[5] = "<td id=l4 title=125>23930/320000</td>" $a[6] = "<td id=l3 title=100>38279/320000</td>" For $i = 0 To 6 ConsoleWrite(_getIt($a[$i]) & @CRLF) Next Func _getIt($line) Local $b = StringRegExp($line, 'id=.1 title=[-]*\d*>(\d*)', 3) If @error Then Return -1 Return $b[0] EndFunc Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Miguel Posted March 8, 2008 Author Share Posted March 8, 2008 Hi, if the ID = 1 stil counts Global $a[7] $a[0] = "<td id=l1 title=-9917>161353/245000</td>" $a[1] = "<td id=l1 title=5467>99353/250000</td>" $a[2] = "<td id=l1 title=-10517>13045/260000</td>" $a[3] = "<td id=l1 title=-9756>163053/271000</td>" $a[4] = "<td id=l1 title=-8520>151530/285000</td>" $a[5] = "<td id=l4 title=125>23930/320000</td>" $a[6] = "<td id=l3 title=100>38279/320000</td>" For $i = 0 To 6 ConsoleWrite(_getIt($a[$i]) & @CRLF) Next Func _getIt($line) Local $b = StringRegExp($line, 'id=.1 title=[-]*\d*>(\d*)', 3) If @error Then Return -1 Return $b[0] EndFunc Mega Thanks guys It Works !!!!!! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now