AutoHotkey Community

It is currently May 27th, 2012, 12:42 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 17 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: February 25th, 2010, 4:06 am 
The range "€-ÿ" will not work with the Unicode build of AutoHotkey_L, since ANSI "€" translates to UTF-16 character code 8364. ErrorLevel shows this:
Quote:
Compile error 8 at offset 19: range out of order in character class
Since the reutrn value is "" in that case, it returns !"", i.e. "valid".

I suggest using "\x80-\xFF" in the regex. It is clearer and works in AHK and AHKL. It is also less likely to cause problems in certain editors.

There's another issue with your regex: it checks for a sequence of between 1 and 253 invalid characters. It does not verify the length of the actual string.
trik wrote:
That is what I sift through to find bad ranges.
I suppose it would be easier and safer to use what is actually documented to be valid.
Quote:
Variable names may be up to 253 characters long and may consist of letters, numbers and the following punctuation: # _ @ $ ? [ ]
However, ? [ ] aren't valid in AHKL. Otherwise I would use this:
Code:
vfv(n) {
   return !!RegExMatch(n, "^[a-zA-Z0-9#_@$?\[\]\x80-\xFF]{1,253}$")
}
It isn't clear in the documentation whether "letters" includes any characters in the \x80-\xFF range, but they certainly aren't all letters. (I know they will work, but that isn't the point.) I would've used \w in place of a-zA-Z0-9_, but I'm not sure whether they're still equivalent in Unicode builds.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 25th, 2010, 2:31 pm 
Offline

Joined: July 15th, 2007, 1:43 am
Posts: 1320
lexikos* wrote:
The range "€-ÿ" will not work with the Unicode build of AutoHotkey_L, since ANSI "€" translates to UTF-16 character code 8364. ErrorLevel shows this:
Quote:
Compile error 8 at offset 19: range out of order in character class
Since the reutrn value is "" in that case, it returns !"", i.e. "valid".

I suggest using "\x80-\xFF" in the regex. It is clearer and works in AHK and AHKL. It is also less likely to cause problems in certain editors.


I do not use AutoHotkey_L, so supporting it is not a priority of mine.

lexikos* wrote:
There's another issue with your regex: it checks for a sequence of between 1 and 253 invalid characters. It does not verify the length of the actual string.


You are correct; added anchors.

_________________
Religion is false. >_>


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page Previous  1, 2

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bon, Google Feedfetcher, maul.esel and 13 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group