Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Can I change \s?

by runrig (Abbot)
on Oct 28, 2011 at 20:55 UTC ( [id://934510]=note: print w/replies, xml ) Need Help??


in reply to Can I change \s?

You can:
my $sp_str = "[\\s".chr(160)."]"; my $sp = qr/$sp_str/; my $str = " ".chr(160)." "; print "Happy\n" if $str =~ /^$sp*$/;

Replies are listed 'Best First'.
Re^2: Can I change \s?
by CountZero (Bishop) on Oct 28, 2011 at 21:51 UTC
    Have a look at perldoc perlrecharclass (Perl Regular Expression Character Classes). If your string is in UTF-8 format, then \s will match all of:
    0x00009 CHARACTER TABULATION h s 0x0000a LINE FEED (LF) vs 0x0000b LINE TABULATION v 0x0000c FORM FEED (FF) vs 0x0000d CARRIAGE RETURN (CR) vs 0x00020 SPACE h s 0x00085 NEXT LINE (NEL) vs 0x000a0 NO-BREAK SPACE h s 0x01680 OGHAM SPACE MARK h s 0x0180e MONGOLIAN VOWEL SEPARATOR h s 0x02000 EN QUAD h s 0x02001 EM QUAD h s 0x02002 EN SPACE h s 0x02003 EM SPACE h s 0x02004 THREE-PER-EM SPACE h s 0x02005 FOUR-PER-EM SPACE h s 0x02006 SIX-PER-EM SPACE h s 0x02007 FIGURE SPACE h s 0x02008 PUNCTUATION SPACE h s 0x02009 THIN SPACE h s 0x0200a HAIR SPACE h s 0x02028 LINE SEPARATOR vs 0x02029 PARAGRAPH SEPARATOR vs 0x0202f NARROW NO-BREAK SPACE h s 0x0205f MEDIUM MATHEMATICAL SPACE h s 0x03000 IDEOGRAPHIC SPACE h s

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (8)
As of 2024-04-23 12:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found