sanku has asked for the wisdom of the Perl Monks concerning the following question:

hi monks, How to match em dash and en dash char using perl regular expression in Linux OS. Thanks in advance.

Replies are listed 'Best First'.
Re: em and en dash problem
by ikegami (Patriarch) on Oct 26, 2010 at 06:49 UTC

    Em dash:

    • use utf8; /—/ (source saved as UTF-8)
    • /\x{2014}/
    • /\N{U+2014}/
    • use charnames ':full'; /\N{EM DASH}/

    En dash:

    • use utf8; /–/ (source saved as UTF-8)
    • /\x{2013}/
    • /\N{U+2013}/
    • use charnames ':full'; /\N{EN DASH}/
      hi, I have tried the same but i am not able to enter the char en and en dash. If i am trying to enter those chars it's displaying as dot. And the code which i have tried is:
      use charnames ':full'; /\N{EM DASH}/; use utf8; $a="."; if($a =~/\x{2014}/) { print "Found"; } else { print "Not Found"; }
      Thanks
        Are you using a utf-8-capable editor? Is the editor using a utf-8-capable font?
        You can use \x and \N in double-quoted literals too, if you donj't want to struggle with your editor.
Re: em and en dash problem
by Anonymous Monk on Oct 26, 2010 at 06:32 UTC
Re: em and en dash problem
by Anonymous Monk on Sep 30, 2011 at 20:23 UTC
    Great post.. Helped me resolving my problem with em and en dash !