nAutoIT 1 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. Share this post Link to post Share on other sites
cageman 4 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 Share this post Link to post Share on other sites
nAutoIT 1 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 "". Share this post Link to post Share on other sites
SmOke_N 211 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. Share this post Link to post Share on other sites
nAutoIT 1 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? Share this post Link to post Share on other sites
SmOke_N 211 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. Share this post Link to post Share on other sites