Sign in to follow this  
Followers 0
therks

Character class not working with regexp

7 posts in this topic

Shouldn't this return 1?

ConsoleWrite(StringRegExp('hello', '[:alpha:]'))

Share this post


Link to post
Share on other sites



Shouldn't this return 1?

ConsoleWrite(StringRegExp('hello', '[:alpha:]'))
Should be:

ConsoleWrite(StringRegExp('hello', '[[:alpha:]]'))

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Should be:

ConsoleWrite(StringRegExp('hello', '[[:alpha:]]'))

;)

YAY!! :)

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

That's it? That's been bugging me forever! That should be mentioned in the doc's cus the way it's presented in there I assumed I should just be able to go like StringRegExp('hello', '([:alpha:]+)') or whatever.

Thanks!

Smoke, are you YAY'ing because you couldn't get it to work either? (I'm hoping to save some of my dignity here) Or was I alone in my misunderstanding?

Share this post


Link to post
Share on other sites

That's it? That's been bugging me forever! That should be mentioned in the doc's cus the way it's presented in there I assumed I should just be able to go like StringRegExp('hello', '([:alpha:]+)') or whatever.

Thanks!

Smoke, are you YAY'ing because you couldn't get it to work either? (I'm hoping to save some of my dignity here) Or was I alone in my misunderstanding?

I wasn't clear on the rules requiring the extra square brackets. Here's one reference that kind of hints at it:

Perl supports the POSIX notation for character classes. This uses names enclosed by [: and :] within the enclosing square brackets. PCRE also supports this notation. For example,

[01[:alpha:]%]

matches "0", "1", any alphabetic character, or "%".

That kind of thing didn't really turn the light on for me, but after a lot of trial and error around it, I hit on the double brackets. AFTERWARDS, I searched for that patter and found a reference to that exact syntax:

Regular Expressions - User guide (scroll down to "POSIX Character Class Definitions"):

These are always used inside square brackets in the form [[:alnum:]] or combined as [[:digit:]a-d]

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Smoke, are you YAY'ing because you couldn't get it to work either? (I'm hoping to save some of my dignity here) Or was I alone in my misunderstanding?

No, I knew it, I was Yaying PsaltyDS because he's repeatedly said he didn't understand RegExp's that well, and he found the solution for you.

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

No, I knew it, I was Yaying PsaltyDS because he's repeatedly said he didn't understand RegExp's that well, and he found the solution for you.

...like when you cheer the slow kid who finally gets fractions.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0