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

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.

Replies are listed 'Best First'.
Re^7: Regex Tool
by Corion (Patriarch) on Jul 04, 2006 at 09:11 UTC

    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