in reply to Re^4: Regex Tool
in thread Regex Tool

Okay I might not have been clear. Why, in with any option checked, is it adding \<. Is that a regex command that I just don't know? The only time i've seen \< in a reged it meant a literal < not something special.


___________
Eric Hodges

Replies are listed 'Best First'.
Re^6: Regex Tool
by Yunus (Novice) on Jul 04, 2006 at 08:59 UTC
    Previous \<, \>, \b indicates boundry. \< is beginning of word, \> is end of word. \b indicates either boundry.
    if u just put '<' in regex, it means character '<', nothing special.

    e.g. /\<hell/ will only match such string/word like 'hello', 'hell' but not 'shell'

    however, i seldom use word anchor. (but maybe someone else does) <\em>

    I hold this statement for a while. No argument on this. I suspend these anchors ( \< , \> ) and just use \b instead. I'll be more careful next time. Sorry everyone. This information actually referred to unreliable / wrong sources. Thanks for all feedbacks.

      Did you test your claim at all?

      use strict; use warnings; while (<DATA>) { chomp; my $matched = /\<hell/ ? 'yes' : 'no'; print "/\\<hell/ matches '$_'? $matched\n" } __DATA__ shell hell this is hell this is hellish this is <hell this is <hellish some shells are bad

      When run, this prints

      Q:\>perl -w tmp.pl 'shell' matches? no 'hell' matches? no 'this is hell' matches? no 'this is hellish' matches? no 'this is <hell' matches? yes 'this is <hellish' matches? yes 'some shells are bad' matches? no

      Please read perlre before making such claims.

        I believe the '\<' syntax is grep-ish (vi too?) for word boundaries.

        a