AutoHotkey Community

It is currently May 26th, 2012, 1:58 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: RegexMatch
PostPosted: January 10th, 2009, 1:03 pm 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 10th, 2009, 2:59 pm 
Offline

Joined: January 10th, 2009, 2:57 pm
Posts: 19
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 January 10th, 2009, 6:30 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 10th, 2009, 3:11 pm 
Offline

Joined: November 4th, 2008, 9:23 am
Posts: 1045
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.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, Exabot [Bot], patgenn123, poserpro and 9 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group