Jump to content

Recommended Posts

Posted (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 by cageman
Posted

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 "".
  • Moderators
Posted

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.

Posted

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?

  • Moderators
Posted (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 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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...