nAutoIT Posted July 26, 2011 Share Posted July 26, 2011 $a = "46 te2s t+" $b = "test" If StringRegExpReplace($a, "[^:alpha:]", "") = StringRegExpReplace($b, "[^:alpha:]", "") Then MsgBox(1, "", StringRegExpReplace($a, "[^:alpha:]", "")) I am trying to compare 2 strings by letters only, but i do not get it. I could not find any examples in the forums or the AutoIt Help that actually use classes. Link to comment Share on other sites More sharing options...
cageman Posted July 26, 2011 Share Posted July 26, 2011 (edited) i am not that good with it either, but someone here helped me in the past too. "[a-zA-Z]" that should be what you are trying. Also http://www.rubular.com/ is an excellent site to test it. what you are doing right now is checking if its not a letter by the way, because of the ^ in front. Edited July 26, 2011 by cageman Link to comment Share on other sites More sharing options...
nAutoIT Posted July 26, 2011 Author Share Posted July 26, 2011 i am not that good with it either, but someone here helped me in the past too. "[a-zA-Z]" that should be what you are trying. Also http://www.rubular.com/ is an excellent site to test it. That works, thanks a lot. what you are doing right now is checking if its not a letter by the way, because of the ^ in front. I was trying to replace all non-letters with "". Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 26, 2011 Moderators Share Posted July 26, 2011 Just to iterate on your original code... The solution is you need to wrap those character classes... Example:$a = "46 te2s t+" $b = "test" If StringRegExpReplace($a, "[^[:alpha:]]", "") = StringRegExpReplace($b, "[^[:alpha:]]", "") Then MsgBox(1, "", StringRegExpReplace($a, "[^[:alpha:]]", "")) 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...
nAutoIT Posted July 26, 2011 Author Share Posted July 26, 2011 Just to iterate on your original code... The solution is you need to wrap those character classes... Example:$a = "46 te2s t+" $b = "test" If StringRegExpReplace($a, "[^[:alpha:]]", "") = StringRegExpReplace($b, "[^[:alpha:]]", "") Then MsgBox(1, "", StringRegExpReplace($a, "[^[:alpha:]]", "")) Dang. I tried "[[^:alpha:]]" and it did not work. Good to know what i did wrong there. In the AutoIt Help it says: [^:class:] Match any character not in the class, but only if the first character. [sic] [:alpha:] letters Is that a mistake in the AutoIt Help? Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 26, 2011 Moderators Share Posted July 26, 2011 (edited) Dang. I tried "[[^:alpha:]]" and it did not work. Good to know what i did wrong there. In the AutoIt Help it says: [^:class:] Match any character not in the class, but only if the first character. [sic] [:alpha:] letters Is that a mistake in the AutoIt Help? Yes, must be. I always look at the entire class string ( eg. [:class:] ) as a single character. Having said that, that would require us to wrap it in brackets ( eg. [[:class:]] ), and to prevent capture [^[:class:]]. Edited July 26, 2011 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...
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