- Dec
- 238
- 2
I'm still back in the dark ages, using TCC v.20 (under Windows 10 Pro).
I've written a bazillion regular expressions over the years but rarely use them in TCC. I've never been clear about using regexes successfully in TCC. (Per the OPTION command, they're set to Perl.)
It's a simple character class: "a" or "b" or "c". I get the "YES" result if the command-line argument is a single character ("a" or "b" or "c"). If the argument is something like "axyz" — no match is noted. Turns out, removing the quotation-marks from around "[abc]" fixes this. But it isn't case-sensitive. It should be. Can case-sensitivity be FORCED in these situations?
As for something like this:
It works if the command-line argument is a single character, "a" or "b" — but not if the argument is longer than one character unless the argument BEGINS with "a" or "b". But, I haven't specified "start of input" using "^" here.
And, "=~" requests a match. It doesn't mean "equals" or "is only" or "starts with." Removing the quotation-marks around "a|b" causes the error "unknown command ENDIFF" — so clearly that isn't the solution. Then, what is?
I've written a bazillion regular expressions over the years but rarely use them in TCC. I've never been clear about using regexes successfully in TCC. (Per the OPTION command, they're set to Perl.)
Code:
iff "%1" =~ "[abc]" then
echo YES
endiff
It's a simple character class: "a" or "b" or "c". I get the "YES" result if the command-line argument is a single character ("a" or "b" or "c"). If the argument is something like "axyz" — no match is noted. Turns out, removing the quotation-marks from around "[abc]" fixes this. But it isn't case-sensitive. It should be. Can case-sensitivity be FORCED in these situations?
As for something like this:
Code:
iff "%1" =~ "a|b" then
echo YES
endiff
It works if the command-line argument is a single character, "a" or "b" — but not if the argument is longer than one character unless the argument BEGINS with "a" or "b". But, I haven't specified "start of input" using "^" here.
And, "=~" requests a match. It doesn't mean "equals" or "is only" or "starts with." Removing the quotation-marks around "a|b" causes the error "unknown command ENDIFF" — so clearly that isn't the solution. Then, what is?