| View previous topic :: View next topic |
| Author |
Message |
Guest
|
Posted: Sat Jan 10, 2009 12:03 pm Post subject: RegexMatch |
|
|
I have a site in a string, and I need help with regxpmatch.
There are about 1-6 lines like this
| Code: | <input type="hidden" id="price_2-Something+Random+things" value="0.124999" />
|
I want that it search for the value. ( 0.124999 )
Every line where I want the value looks like this:
| Code: | | <input type="hidden" id="price_2-%RANDOM%" value="%VALUE%" /> |
And I only want that value. |
|
| Back to top |
|
 |
gargoyle888
Joined: 10 Jan 2009 Posts: 16
|
Posted: Sat Jan 10, 2009 1:59 pm Post subject: |
|
|
Selects the whole line for any line that contains "0.124999" (without the quotes):
.+0\.124999.+
| Code: |
HayStack = <input type="hidden" id="price_2-Something+Random+things" value="0.124999" />
Needle = .+0.1248999.+
DoesItExist := RegExMatch(HayStack, Needle)
if DoesItExist = 1
Msgbox, The string contains 0.1248999
else
Msgbox, The string does not contain 0.1248999
exitapp
|
Last edited by gargoyle888 on Sat Jan 10, 2009 5:30 pm; edited 1 time in total |
|
| Back to top |
|
 |
animeaime
Joined: 04 Nov 2008 Posts: 1045
|
Posted: Sat Jan 10, 2009 2:11 pm Post subject: |
|
|
here you go
| Code: | TheRegEx = <input type="hidden" id="price_2-(?P<Random>.*?)" value="(?P<Value>.*?)" />
Line = <input type="hidden" id="price_2-Something+Random+things" value="0.124999" />
if RegExMatch(Line, TheRegEx, Match)
{
MsgBox, % MatchRandom . "`n" . MatchValue
}
return |
If you want to understand the syntax you can either check out The Regular Expressions (RegEx) - Quick Reference or ask. _________________ As always, if you have any further questions, don't hesitate to ask.
Add OOP to your scripts via the Class Library. Check out my scripts. |
|
| Back to top |
|
 |
|