Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Regexp \N{name} (use of \e)

by gautam_9jan (Initiate)
on Feb 03, 2011 at 10:04 UTC ( [id://885948]=perlquestion: print w/replies, xml ) Need Help??

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

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Regexp \N{name}
by cjb (Friar) on Feb 03, 2011 at 10:38 UTC
    #!/opt/perl/bin/perl use strict; use warnings; use charnames ':full'; binmode STDOUT, ":utf8"; my $string = ':)'; print "$string becomes: "; $string =~ s/:\)/\N{WHITE SMILING FACE}/; print "$string\n$string becomes: "; $string =~ s/\N{WHITE SMILING FACE}/\N{BLACK SMILING FACE}/; print "$string\n$string becomes: "; $string =~s/\N{BLACK SMILING FACE}/:\)/; print "$string\n";

    That should cover most uses of \N{CHARNAME}.

    charnames and perlre are the best references.

    Update: added #! to example
    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Regexp \N{name}
by MidLifeXis (Monsignor) on Feb 03, 2011 at 10:37 UTC

    perlre should have a section on it. It appears that perlre points to charnames. The charnames page appears to have a plethora of examples.

    If you would show us some code that you are having problems with, perhaps we could see what is happening.

    --MidLifeXis

Re: Regexp \N{name}
by Anonyrnous Monk (Hermit) on Feb 03, 2011 at 10:35 UTC
    how I use special character \N{name} in regular expression

    Example:

    #!/usr//bin/perl -wl use strict; use charnames ':full'; my $string = "foo \N{COPYRIGHT SIGN} bar"; print "matched" if $string =~ /\N{COPYRIGHT SIGN}/;

    The list of names can be found in the file .../unicore/NamesList.txt that comes with Perl.

Re: Regexp \N{name}
by jethro (Monsignor) on Feb 03, 2011 at 10:54 UTC

    Just like any other character I suspect. If you look into perldoc perlrecharclass, it is mentioned that \N{} are valid in regexes. And when I tested it it worked:

    > perl -e '$_="haba\N{U+263A}ugo"; $n= m/(\N{U+263A})/; print $n;' 1
Re^2: Regexp \N{name} (use of \e)
by ikegami (Patriarch) on Feb 04, 2011 at 08:35 UTC

    how i use \e (special character) in perl program

    Your question doesn't make sense. Are you asking what \e does in double-quoted string literals? It evaluates to the ESC character (0x1B). See "Quote and Quote-like Operators" in perlop for the documentation for double-quoted string literals.

Re: use of \e
by cjb (Friar) on Feb 04, 2011 at 07:23 UTC

    Please don't change your question, if you have another question to ask then post another node

    You can find most of the answerss your looking for in perlre. It's going to get rather boring if you ask for every character one by one

    Updated: See: Re^2: Regexp \N{name} (use of \e) by ikegami below for a much better answer
A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2025-03-16 23:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When you first encountered Perl, which feature amazed you the most?










    Results (54 votes). Check out past polls.