MikeP Posted May 22, 2008 Posted May 22, 2008 Hi. I'm clearly not used to Autoit's Regexps and that's driving me crazy, here are example strings :http://www.random.com/dir01/files/test.htmhttp://www.random.com/dir02/files/http://www.random.com/dir03/files/test.htmhttp://www.random.com/dir04/files/test.htmhttp://www.random.com/dir05/files/test.htmhttp://www.random.com/dir06/files/goal : detecting empty onesIn UltraEdit (i'm a long time user), it's very easy, this is done like this :%*files/$ % = line start * = any character $ = line end (not CR or CRLF)I want to translate it in AutoIt but I simply can't get it.I tried $test = StringRegExp($urlstring, ".*files//", 0)but this never match... and I want it to match the lines that ends with files/Could anyone with some RegExp knowledge help me a bit please? Thanks.
Monamo Posted May 22, 2008 Posted May 22, 2008 (edited) Hi. I'm clearly not used to Autoit's Regexps and that's driving me crazy, here are example strings :http://www.random.com/dir01/files/test.htmhttp://www.random.com/dir02/files/http://www.random.com/dir03/files/test.htmhttp://www.random.com/dir04/files/test.htmhttp://www.random.com/dir05/files/test.htmhttp://www.random.com/dir06/files/goal : detecting empty onesIn UltraEdit (i'm a long time user), it's very easy, this is done like this :%*files/$ % = line start * = any character $ = line end (not CR or CRLF)I want to translate it in AutoIt but I simply can't get it.I tried $test = StringRegExp($urlstring, ".*files//", 0)but this never match... and I want it to match the lines that ends with files/Could anyone with some RegExp knowledge help me a bit please? Thanks.Just a quick syntactical switch (pattern = "files/\z") - The pattern details are lengthy, but pretty well fleshed out in the help file under StringRegExp(). Here's a quick code and dirty code example to verify the pattern:CODE$string1 = "http://www.random.com/dir01/files/test.htm"$string2 = "http://www.random.com/dir02/files/"$string3 = "http://www.random.com/dir03/files/test.htm"$string4 = "http://www.random.com/dir04/files/test.htm"$string5 = "http://www.random.com/dir05/files/test.htm"$string6 = "http://www.random.com/dir06/files/"_TestString($string1)_TestString($string2)_TestString($string3)_TestString($string4)_TestString($string5)_TestString($string6)Func _TestString($str) $sPattern = "files/\z"$iMatchPattern = StringRegExp($str, $sPattern, 0) If $iMatchPattern Then ConsoleWrite("Match *** " &$str &@CRLF) Else ConsoleWrite("No match *** " &$str &@CRLF) EndIfEndFuncEdit: Updated suggested pattern to a shorter valid pattern match Edited May 22, 2008 by Monamo - MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]
MikeP Posted May 22, 2008 Author Posted May 22, 2008 (edited) Thanks, you enlightened me of something quite easy but since i'm beginner in that syntax... Btw there was a mistake .. I didn't have to escape the / since it's not a backslash \ .. well, you know what I mean. Anyway my problem was the description in helpfile : \z Match only at end of string where in fact.. that MEANS 'end of string' I never understood that. Thanks ! Edited May 22, 2008 by MikeP
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