AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

RegexMatch

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Sat Jan 10, 2009 12:03 pm    Post subject: RegexMatch Reply with quote

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

PostPosted: Sat Jan 10, 2009 1:59 pm    Post subject: Reply with quote

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
View user's profile Send private message
animeaime



Joined: 04 Nov 2008
Posts: 1045

PostPosted: Sat Jan 10, 2009 2:11 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group