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.