WAD Regex match on \h

Nov 13, 2008
255
3
www.thedave.me
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?
 
Aug 2, 2011
258
4
Berlin, Germany
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!
 
May 20, 2008
11,401
99
Syracuse, NY, USA
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.
 
May 20, 2008
11,401
99
Syracuse, NY, USA
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
 
Nov 13, 2008
255
3
www.thedave.me
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.
 

rconn

Administrator
Staff member
May 14, 2008
12,345
150
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
Thread starter Title Forum Replies Date
F %@regex["^-","-a"] returns 0, "^-" =~ "-a" is false (no match) Support 4
mikea How to? Regex match when there shouldn't be (?) Support 18
JohnQSmith Regex renaming Support 2
vefatica TPIPE: unbalanced escaped quotes in a regex? Support 5
rps Regex problem: \xnn not recognized as a hex character Support 0
old coot Regex problem: \xnn not recognized as a hex character Support 12
R Regex using ^ Support 2
T Regex engine doesn't recognize native DOS line endings Support 2
P Simple RegEx copy Support 9
samintz WAD Regex Analyzer Support 1
D How to? Use typed envars using regex. Support 3
P Renaming with a RegEx Support 1
R How to? use @everything perl regex Support 2
C v18 regex help please Support 1
C Font of RegEx Analyzer Support 0
D Regex problem Support 17
JohnQSmith Fixed Copying with regex (several issues) Support 7
D Help needed to get a regex to work Support 3
Ville Regex & conditionals Support 9
samintz Regex Rename Support 2
vefatica @REGEX: behavior vs. documentation Support 2
vefatica @REGEX revisited Support 4
vefatica @REGEX question Support 6
vefatica Regex question Support 5
B Regex and Replace Support 6
Stefano Piccardi detecting BOM, FFIND multibyte regex Support 18
dcantor FFIND syntax -- is /E"regex" /X supported? Support 2
P Renaming files with regex. Support 6
B "Fun" with DO and Regex Support 12
P Need to use a regex in a "for" loop. Support 54
D How move cursor out of popup edit control after no match? Support 14
D CD exact match Support 5
S 32b Build 54 does not match MD5 in tcmd.aiu Support 7
S How to? Set the timestamp of ZIP command built archive to match latest member Support 8
samintz How to? DIR listing for exact match Support 1
J Tab-Complete annoyance when directory name and file basename match and tab on '.' Support 1
Phileosophos Can FFIND match file names with a regular expression? Support 19
H Help file pdf dates do not match Support 3

Similar threads