Sign in to follow this  
Followers 0
Simucal

Quick Stringregexp Usage Question

3 posts in this topic

#1 ·  Posted (edited)

Here is what I am attempting to match:

"tendayIconDay0" SRC="http://image.weather.com/web/common/wxicons/31/12.gif"

Except the "tendayIconDay0" can be 0-10, and the numbers in "/wxicons/31/12.gif" can be any two digit number as well. The only output I want put into the array is the actual address of the image.

So, my question is:

Do I have to put the items that change in the pattern into groups of their own? Like:

StringRegExp($10DayFile,'(?:tendayIconDay)(?:[0-9]{1,2})(?:" SRC=")(http://image.weather.com/web/common/wxicons/)([0-9]{1,2})(/)([0-9]{1,2})(.gif)(?:")',1)

Or can the groups be combined like:

StringRegExp($10DayFile,'(?:tendayIconDay[0-9]{1,2}" SRC=")(http://image.weather.com/web/common/wxicons/[0-9]{1,2}/[0-9]{1,2}.gif(?:")',1)

And lastly, do either of these seem valid? This is my first attempt at using StringRegExp. I have read the tutorial (which I found very helpful) but need a little more guidance.

Thanks in advance,

-Sim

Edited by Simucal

AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc)

Share this post


Link to post
Share on other sites



Ok, so after some further research I found that:

StringRegExp($10DayFile,'(?:tendayIconDay)(?:[0-9]{1,2})(?:" SRC=")(http://image.weather.com/web/common/wxicons/)([0-9]{1,2})(/)([0-9]{1,2})(.gif)(?:")',1)

Is not what I want because each sub group becomes its own item in the array.

I also found that I need to set the option for StringRegExp to '3' so it will search the ENTIRE string.

After further playing around with it, I saw that my second example was missing a ")" and it works great!

StringRegExp($10DayFile,'(?:tendayIconDay[0-9]{1,2}" SRC=")(http://image.weather.com/web/common/wxicons/[0-9]{1,2}/[0-9]{1,2}.gif)(?:")',3)

So.. I figured it out :think:


AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc)

Share this post


Link to post
Share on other sites

Ok, so after some further research I found that:

StringRegExp($10DayFile,'(?:tendayIconDay)(?:[0-9]{1,2})(?:" SRC=")(http://image.weather.com/web/common/wxicons/)([0-9]{1,2})(/)([0-9]{1,2})(.gif)(?:")',1)

Is not what I want because each sub group becomes its own item in the array.

I also found that I need to set the option for StringRegExp to '3' so it will search the ENTIRE string.

After further playing around with it, I saw that my second example was missing a ")" and it works great!

StringRegExp($10DayFile,'(?:tendayIconDay[0-9]{1,2}" SRC=")(http://image.weather.com/web/common/wxicons/[0-9]{1,2}/[0-9]{1,2}.gif)(?:")',3)

So.. I figured it out :think:

I have a UDF I use for this if you want it:
$File = @DesktopDir & '\SomeFileName.txt'

Local $receive = _StringRegExp_Between($File, "tendayIconDay", ".gif")

For $i = 0 To UBound($receive) - 1
    MsgBox(0, 'Info', '"tendayIconDay' & $receive[$i] & '.gif"')
Next

Func _StringRegExp_Between($s_FilePath, $s_Start, $s_End)
    $h_FRead = FileRead($s_FilePath, FileGetSize($s_FilePath))
    $a_Array = StringRegExp($h_FRead, '(?:' & $s_Start & ')(.*?)(?:' & $s_End & ')', 3)
    If Not @error Then Return $a_Array
EndFunc

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

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  
Followers 0