Jump to content
Sign in to follow this  
dbzfanatic

StringRegExp pattern

Recommended Posts

dbzfanatic

I've never really used StringRegExp before but I need to use it to check to see if something is in a string. Here's an example of the pattern

&sid=7e2ee2f398cb83c699e476725877992e

How would I make a pattern for this? I need to remove that from the string returned so I can save it as a normal url and since I know SID are temporary (session id) if that were saved as a url it wouldn't work after the time specified on the board had passed. Can anyone help me?

Share this post


Link to post
Share on other sites
PsaltyDS

I've never really used StringRegExp before but I need to use it to check to see if something is in a string. Here's an example of the pattern

&sid=7e2ee2f398cb83c699e476725877992e

How would I make a pattern for this? I need to remove that from the string returned so I can save it as a normal url and since I know SID are temporary (session id) if that were saved as a url it wouldn't work after the time specified on the board had passed. Can anyone help me?

Try this:
Global $sString = "Stuff1234567890MoreStuff&sid=7e2ee2f398cb83c699e476725877992eYetMoreStuff"
Global $avString = StringRegExp($sString, "\&sid=[[:xdigit:]]+", 1)
MsgBox(64, "Result", $avString[0])

;)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
Zinthose

This one dose the trick and will return an array of all the values of the matches found.

Dim $String = "&sid=7e2ee2f398cb83c699e476725877992e"
Dim $Pattern = "(?i)&sid=((?:\d|[A-F]){32})"

Dim $Matches = StringRegExp($String, $Pattern, 3)

For $i = 0 to UBound($Matches) - 1
    MsgBox(4096, "RegEx Result", $Matches[$i])
NextoÝ÷ Úȳz,¥©ì·)^
Edited by Zinthose

--- TTFN

Share this post


Link to post
Share on other sites
dbzfanatic

Thanks guys, really helps. Thanks for explaining how your pattern worked too Zinthose, gave me a bit more insight into how the function works so thank you very much. Testing them now so I'll edit the post when I have results.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×