Buffo Posted May 8, 2006 Share Posted May 8, 2006 I need a Regex for the following scenario:http://www.address.com/folder/xyz.htmlXThe X can be a whitespace character (\s) or a " (ASCII 34).I am not able to put special characters in an or statement.StringRegExp($test, "(http://www.address.com/folder/.+\.html[\s|"]orStringRegExp($test, "(http://www.address.com/folder/.+\.html[\s"]doesn't work.Can anyone help me?Thx a lot Regards,Buffo Link to comment Share on other sites More sharing options...
Simucal Posted May 8, 2006 Share Posted May 8, 2006 (edited) Maybe: StringRegExp($test, '(http://www.address.com/folder/.+?html[^:alpha:]{1})',3) Edited May 8, 2006 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) Link to comment Share on other sites More sharing options...
Buffo Posted May 8, 2006 Author Share Posted May 8, 2006 Thx for your reply. But this won't work. It has to be \s or " and nothing else. Regards Link to comment Share on other sites More sharing options...
Buffo Posted May 8, 2006 Author Share Posted May 8, 2006 Perhaps another expressed question will help:Is it possible and if yes - how is it possible to OR characters with specialmeanings?For example: \s OR \w OR \dWhat's the regular expression for this term?[\s|\w|\d] isn't working...Anyone an idea?Regards,Buffo Link to comment Share on other sites More sharing options...
Simucal Posted May 8, 2006 Share Posted May 8, 2006 (edited) StringRegExp($string, '(http://www.address.com/folder/.+?html\s{1})|(http://www.address.com/folder/.+?html"{1})|(http://www.address.com/folder/.+?html\w{1})',3) Or something like: StringRegExp($string, 'StringRegExp($string, '(http://www.address.com/folder/.+?html(\s{1}|"{1}|\w{1}))',3) With this last example however, end character \s " or \w will be everyother item in the array, it didnt work as a non-capturing group. This shows nested groups. I believe the reason [\w\s"] doesnt work is like it says in the help file: Note that special characters do not retain their special meanings inside a set, with the exception of \b, \n, \r, \t, and \\. \^, \- and \] match the escaped character inside a set. So \w and \s dont work. Edited May 8, 2006 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) Link to comment Share on other sites More sharing options...
neogia Posted May 8, 2006 Share Posted May 8, 2006 (edited) As it stands currently, you can't indicate sets with an escaped character.[\s]This means nothing to the StringRegExp() function; in fact, you will receive an error in the pattern string. In order to do what you intend to, you must use something along the lines of this:StringRegExp($test, '(http://www.address.com/folder/.+?html[:space:|"])')Edit: Oops, Simucal beat me to the reason why it wouldn't work. Edited May 8, 2006 by neogia [u]My UDFs[/u]Coroutine Multithreading UDF LibraryStringRegExp GuideRandom EncryptorArrayToDisplayString"The Brain, expecting disaster, fails to find the obvious solution." -- neogia Link to comment Share on other sites More sharing options...
Simucal Posted May 8, 2006 Share Posted May 8, 2006 I knew neogia would come to the rescue 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) Link to comment Share on other sites More sharing options...
Buffo Posted May 8, 2006 Author Share Posted May 8, 2006 (edited) Thx for your help After a few trial and error it seems to work with completing \> Edited May 8, 2006 by Buffo Link to comment Share on other sites More sharing options...
Buffo Posted May 9, 2006 Author Share Posted May 9, 2006 (edited) Another question How to "OR" more than one character? How to realize? With one character [ab] or [a|b] no problem (btw. What's the difference between?) But with more than one character it won't work for me: [ab|cd] [(ab)|(cd)] What's the correct Syntax? Thx in advance. Regards, Buffo Edited May 9, 2006 by Buffo Link to comment Share on other sites More sharing options...
neogia Posted May 9, 2006 Share Posted May 9, 2006 StringRegExp("test", '([te]|[st])', 1) This returns "t". [u]My UDFs[/u]Coroutine Multithreading UDF LibraryStringRegExp GuideRandom EncryptorArrayToDisplayString"The Brain, expecting disaster, fails to find the obvious solution." -- neogia Link to comment Share on other sites More sharing options...
Thatsgreat2345 Posted May 9, 2006 Share Posted May 9, 2006 i dont think that returns t Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 9, 2006 Moderators Share Posted May 9, 2006 i dont think that returns tLOL, if you use it right it does:$Test = StringRegExp("test", '([te]|[st])', 1) MsgBox(0, '', $Test[0]) 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. Link to comment Share on other sites More sharing options...
Buffo Posted May 9, 2006 Author Share Posted May 9, 2006 Sorry, but this is not what I want :"> Or perhaps I don't understand really Here an other precise (but stupid ) example that explains what I want: String: "fat fet fit fot fut" I only want to get "fet" and "fot": StringRegExp($string, "(f[eo]t)", 3) or StringRegExp($string, "(f[e|o]t)", 3) will work. String: "faat feet fiit foot fuut" I want to get only "feet" and "foot" as result. StringRegExp($string, "(f[ee|oo]t)", 3) won't work. I need here the correct syntax (even if there are more than 2 characters that should be "OR"-ed) Regards, Buffo Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 9, 2006 Moderators Share Posted May 9, 2006 (edited) I doubt seriously this is right, I would just use StringInStr() for something to be word specific personally$sRegExp = StringRegExp("fat fet fit fot fut", '(f[e]t|f[o]t)', 3) If IsArray($sRegExp) Then For $i = 0 To UBound($sRegExp) - 1 MsgBox(0, $i, $sRegExp[$i]) Next EndIf Edit: Actually the more I think about it, these are all the same:$sRegExp = StringRegExp("fat fet fit fot fut", '(f[e]t|f[o]t)', 3) If IsArray($sRegExp) Then For $i = 0 To UBound($sRegExp) - 1 MsgBox(0, $i, $sRegExp[$i]) Next EndIf $sRegExp2 = StringRegExp('faat feet fiit foot fuut', '(f[e][e]t|f[o][o]t)', 3) If IsArray($sRegExp2) Then For $j = 0 To UBound($sRegExp2) - 1 MsgBox(0, $j, $sRegExp2[$j]) Next EndIf $sRegExp3 = StringRegExp("fat fet fit fot fut", '(fet|fot)', 3) If IsArray($sRegExp3) Then For $k = 0 To UBound($sRegExp3) - 1 MsgBox(0, $k, $sRegExp3[$k]) Next EndIf $sRegExp4 = StringRegExp('faat feet fiit foot fuut', '(feet|foot)', 3) If IsArray($sRegExp4) Then For $l = 0 To UBound($sRegExp4) - 1 MsgBox(0, $l, $sRegExp4[$l]) Next EndIf Edit2: This looked more like what you were looking for... But of course could be wrong:$sRegExp = StringRegExp("fat fet feet fot fut foot", '(f[e]{1,2}t|f[o]{1,2}t)', 3) If IsArray($sRegExp) Then For $i = 0 To UBound($sRegExp) - 1 MsgBox(0, $i, $sRegExp[$i]) Next EndIf Edited May 9, 2006 by SmOke_N 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. Link to comment Share on other sites More sharing options...
Buffo Posted May 9, 2006 Author Share Posted May 9, 2006 Ah, I see... I have to use round brackets instead of the squared.Now there is a little understanding problem:String: "faat feet fiit foot fuut"Regular Expression: (f(ee|oo)t) returns: 1. oo2. foot3. ee4. feetBut I only want the whole (2+4) expression. This can only be a simple thing. Could you help me a last time? Regards,Buffo Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 9, 2006 Moderators Share Posted May 9, 2006 (edited) Ah, I see... I have to use round brackets instead of the squared. Now there is a little understanding problem: String: "faat feet fiit foot fuut" Regular Expression: (f(ee|oo)t) returns: 1. oo 2. foot 3. ee 4. feet But I only want the whole (2+4) expression. This can only be a simple thing. Could you help me a last time? Regards, BuffoI'd like to personally find a better/cleaner solution but I must admit... the time is catching up to me, you could do something like this I guess:$sRegExp = StringRegExp("faat feet fiit foot fuut", '(f(ee|oo)t)', 3) If IsArray($sRegExp) Then For $i = 0 To UBound($sRegExp) - 1 If Mod($i, 2) <> 0 Then MsgBox(0, $i, $sRegExp[$i]) Next EndIf Edit: This is cleaner:$sRegExp = StringRegExp("faat feet fiit foot fuut", '(f[e|o]{2}t)', 3) If IsArray($sRegExp) Then For $i = 0 To UBound($sRegExp) - 1 MsgBox(0, $i, $sRegExp[$i]) Next EndIfBut I still don't know if it's right. Edit2: If your just trying to find the word that has the double letters in them, this might be fun too:$sRegExp = StringRegExp("need faat feet fiit foot fuut loot hoot", '([a-z][e|o]{2}[a-z])', 3) If IsArray($sRegExp) Then For $i = 0 To UBound($sRegExp) - 1 MsgBox(0, $i, $sRegExp[$i]) Next EndIf Edit3: Or even this:$sRegExp = StringRegExp("need faat feet fiit foot fuut loot hoot sheeze", '([a-z]{1, 2}[e|o]{2}[a-z]{1, 2})', 3) If IsArray($sRegExp) Then For $i = 0 To UBound($sRegExp) - 1 MsgBox(0, $i, $sRegExp[$i]) Next EndIf Edit4: Or maybe:$sRegExp = StringRegExp("need faat feet fiit foot fuut loot hoot Sheeze", '(\a{1,2}[e|o]{2}\a{1,2})', 3) If IsArray($sRegExp) Then For $i = 0 To UBound($sRegExp) - 1 MsgBox(0, $i, StringLen($sRegExp[$i]) & @CRLF & $sRegExp[$i]) Next EndIf Edit5: Or maybe:$sRegExp = StringRegExp("need faat feet fiit foot fuut loot hoot Sheeze", '(\a*[e|o]{2}\a*)', 3) If IsArray($sRegExp) Then For $i = 0 To UBound($sRegExp) - 1 MsgBox(0, $i, StringLen($sRegExp[$i]) & @CRLF & $sRegExp[$i]) Next EndIfI liked this one the best I think. Edit6: Or Maybe:$sRegExp = StringRegExp("need faat feet fiit foot fuut loot hoot Sheeze", '(\a*[e*|o*]\a*)', 3) If IsArray($sRegExp) Then For $i = 0 To UBound($sRegExp) - 1 MsgBox(0, $i, StringLen($sRegExp[$i]) & @CRLF & $sRegExp[$i]) Next EndIfOk man, I'm off to bed, good luck! Edited May 9, 2006 by SmOke_N 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. Link to comment Share on other sites More sharing options...
neogia Posted May 9, 2006 Share Posted May 9, 2006 ...Regular Expression: (f(ee|oo)t)...Well, actually, this is supposed to work: Regular Exp[b][/b]ression: (f(?:ee|oo)t) The "?:" added in there means "non-capturing group" but it seems to error out. This seems to be a bug, but I'll do more investigating. @SmOke_N: That is hilarious how many examples you came up with. There's always at least a gazillion ways to make one regular expression. [u]My UDFs[/u]Coroutine Multithreading UDF LibraryStringRegExp GuideRandom EncryptorArrayToDisplayString"The Brain, expecting disaster, fails to find the obvious solution." -- neogia Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now