newuserautoit Posted March 24, 2008 Posted March 24, 2008 I am trying to run StringRegExp('< No < No < No < Bingo > No > No > No >','<(.*?)>',3), I want it to return " Bingo ", instead it returns " No < No < No < Bingo ". I know that "?" will find the minimum match, but it seems like it only applies to the end string only, is the a way to also apply minimum matching to the start string? Thanks in advance.
zackrspv Posted March 24, 2008 Posted March 24, 2008 (edited) I am trying to run StringRegExp('< No < No < No < Bingo > No > No > No >','<(.*?)>',3), I want it to return " Bingo ", instead it returns " No < No < No < Bingo ". I know that "?" will find the minimum match, but it seems like it only applies to the end string only, is the a way to also apply minimum matching to the start string? Thanks in advance. I'm no expert, truuuuuuust me, but as i'm learning more and mroe about regex's as i use them so frequently, i downloaded a program called The Regex Coach, it's free, so look it up, it'll help you. $nOffset = 1 While 1 $array = StringRegExp('< No < No < No < Bingo > No > No > No >','\<.*\<(.*?)>',1, $nOffset) If @error = 0 Then $nOffset = @extended Else ExitLoop EndIf for $i = 0 to UBound($array) - 1 msgbox(0, "RegExp Test with Option 1 - " & $i, $array[$i]) Next WEnd Give it a try, it finds bingo rather easily. Now, like I said, i'm no expert, in any means, so I may be way wrong But, from what I've been told you have to escape <'s and then if you use .* it tells it to find whatever (pretty much ignors anything after that, and your last syntax \<(.*?)> will tell it find what is between the < and the >. EDIT: Now that I think on it, you could just do this: .*\<(.*?)> Since your just looking inside of the brackets And, if you do indeed have spaces between your text and your brackets you could use: .*\<\s(.*?)\s> Which should just return the text one space after the < and one space before the > Like i said: I AM NO EXPERT I'm sure many on here would correct me, so expect more results if i'm wrong Edited March 24, 2008 by zackrspv -_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë ë§§ëñ§ë øƒ !ïƒë.
Moderators SmOke_N Posted March 24, 2008 Moderators Posted March 24, 2008 "<\s*(\w+)\s*>" 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.
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