Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

em and en dash problem

by sanku (Beadle)
on Oct 26, 2010 at 06:23 UTC ( [id://867404]=perlquestion: print w/replies, xml ) Need Help??

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 !

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://867404]
Approved by ikegami
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2024-04-24 03:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found