1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WAD Regex match on \h

Discussion in 'Support' started by thedave, Jul 2, 2012.

  1. thedave

    Joined:
    Nov 13, 2008
    Messages:
    253
    Likes Received:
    2
    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?
     
  2. Frank

    Joined:
    Aug 2, 2011
    Messages:
    258
    Likes Received:
    4
    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!
     
  3. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,952
    Likes Received:
    30
    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.
     
  4. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,952
    Likes Received:
    30
    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
    
     
  5. thedave

    Joined:
    Nov 13, 2008
    Messages:
    253
    Likes Received:
    2
    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.
     
  6. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,859
    Likes Received:
    83
    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."
     

Share This Page