Welcome!

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

SignUp Now!

WAD Regex match on \h

Nov
257
3
Can anyone tell me what I'm doing wrong with \h and \H regex matches?

First off, to confirm that character classes are working at all:
Code:
[C:\]echo %@regex[\d,5] %@regex[\w,5] %@regex[\d,a] %@regex[\w,a]
1 1 0 1

But when I try \h and \H I get a bunch of zeros. This makes little sense to me since \H should return the opposite of \h.
Code:
[C:\]echo %@regex[\h,5] %@regex[\H,5] %@regex[\h,a] %@regex[\H,a] %@regex[\h,z] %@regex[\H,z]
0 0 0 0 0 0

In fact, if I replace \h with the help file's definition (and define \H as not-the-help-file's-definition-of-\h), it works as expected:
Code:
echo %@regex[[0-9a-fA-F],5] %@regex[[^0-9a-fA-F],5] %@regex[[0-9a-fA-F],a] %@regex[[^0-9a-fA-F],a] %@regex[[0-9a-fA-F],z] %@regex[[^0-9a-fA-F
],z]
1 0 1 0 0 1

PEBCAK or bug?
 
Huhu - I didn't know that before: PEBCAK! :p
There is also PEBKAC, PICNIC and ID-10T (one delta ten tango)
**rofl**
You just made my day!
 
Can anyone tell me what I'm doing wrong with \h and \H regex matches?

First off, to confirm that character classes are working at all:
Code:
[C:\]echo %@regex[\d,5] %@regex[\w,5] %@regex[\d,a] %@regex[\w,a]
1 1 0 1

But when I try \h and \H I get a bunch of zeros. This makes little sense to me since \H should return the opposite of \h.
Code:
[C:\]echo %@regex[\h,5] %@regex[\H,5] %@regex[\h,a] %@regex[\H,a] %@regex[\h,z] %@regex[\H,z]
0 0 0 0 0 0

In fact, if I replace \h with the help file's definition (and define \H as not-the-help-file's-definition-of-\h), it works as expected:
Code:
echo %@regex[[0-9a-fA-F],5] %@regex[[^0-9a-fA-F],5] %@regex[[0-9a-fA-F],a] %@regex[[^0-9a-fA-F],a] %@regex[[0-9a-fA-F],z] %@regex[[^0-9a-fA-F
],z]
1 0 1 0 0 1

PEBCAK or bug?
Have you selected "Ruby" as your regular expression type? I don't think \h and \H have a meaning in the Perl syntax and, perhaps, in other syntaxes.
 
It does work when Ruby is selected. See the OPTION dialog, Advanced tab.
Code:
g:\tc13> option //regularexpressions=ruby
 
g:\tc13> echo %@regex[\H,5]
0
 
g:\tc13> echo %@regex[\h,5]
1
 
g:\tc13> option //regularexpressions=perl
 
g:\tc13> echo %@regex[\H,5]
0
 
g:\tc13> echo %@regex[\h,5]
0
 
Have you selected "Ruby" as your regular expression type? I don't think \h and \H have a meaning in the Perl syntax and, perhaps, in other syntaxes.

I had not -- I initially just assumed that the information in the help file would reflect default operation. Thanks!

Perhaps the documentation could/should include some sort of note that the options listed are not TCC's default behaviour.
 
I had not -- I initially just assumed that the information in the help file would reflect default operation. Thanks!

Perhaps the documentation could/should include some sort of note that the options listed are not TCC's default behaviour.

The help already says:

"This section covers the Ruby regular expression syntax. For information on Perl regular expression syntax, see your Perl documentation or http://www.perl.com/doc/manual/html/pod/perlre.html."
 

Similar threads

Back
Top