Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

%@regex["^-","-a"] returns 0, "^-" =~ "-a" is false (no match)

May
24
0
Let's see if the string "-a" looks like an option, that is, whether it begins with a hyphen:
Code:
echo %@regex["^-","-a"]
0
How odd. Maybe it must match the full string, even though that would make @regexindex[] meaningless:
Code:
echo %@regex["^-.*$","-a"]
0
Even weirder. Let me try that in in a Python script … works. Perl … works. gawk … works. Hmm. Let's try TCC again, but instead of the Ruby flavour we'll try TCC's perl, grep, gnu, and Python flavours … Nope. OK, back to Ruby flavour, just for consistency.
Code:
echo %@regex["-","-a"]
1
Well, something works, at least. Regrettably (and expectedly), however, I wanted an anchored search, and this now also matches:
Code:
echo %@regex["-","x-a"]
1
Let's give this one last try:
Code:
echo %@regex["\A-","-a"]
0
Nope. At least the starting anchors dislike me.
What am I doing wrong, please?

Thanks,
Felix.
 
It works without the quotes: echo %@regex[^-,-a]
The documentation says the quotes are needed when there is a space in the expression.
Maybe there is something confusing here because the caret is also an escape character for TCC.
 
Apparently the quotes are preserved in the second parameter.

Code:
v:\> echo %@regex["^-",-a]
1

v:\> echo %@regex["^^"","a]
1

v:\> echo %@regex["^a","a]
0
 
It works without the quotes: echo %@regex[^-,-a]
The documentation says the quotes are needed when there is a space in the expression.
Maybe there is something confusing here because the caret is also an escape character for TCC.
It didn't realy work. Without the quotes on the first parameter, the '^' got lost.

Code:
v:\> echo %@regex[^-,a-a]
1
 
Christian,
Vincent,

thanks a million! I can make sure the second string always will be quoted and then add the intial quote to the regex, or just make that initial quote an optional match.

Thanks!!

Felix.
 
Back
Top
[FOX] Ultimate Translator
Translate