develooper Front page | perl.unicode | Postings from February 2003

Odd regexp behavior

Thread Next
From:
Markus Kuhn
Date:
February 26, 2003 10:02
Subject:
Odd regexp behavior
Message ID:
E18o4nw-0008Ly-00@wisbech.cl.cam.ac.uk
Dear UTF-8 regular expression gurus:

$ perl -e '$x = "\x{2019}\nk"; $x =~ s/(\S)\n(\S)/$1 $2/sg; print "$x\n";'
'    <= this denotes a \x{2019} followed by \n
k
$ perl -e '$x = "b\nk"; $x =~ s/(\S)\n(\S)/$1 $2/sg; print "$x\n";'
b k

Any idea, why the Unicode apostrophe is not matched by a \S in the first
case, whereas the 'b' is?

Also note that

$ perl -e 'print (("\x{2019}" =~ /\S/) . "\n");'
1

so \x{2019} *does* match \S in principle ... odd.

(Perl v5.6.0 built for i386-linux)

Markus

-- 
Markus Kuhn, Computer Lab, Univ of Cambridge, GB
http://www.cl.cam.ac.uk/~mgk25/ | __oo_O..O_oo__


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About