develooper Front page | perl.perl5.porters | Postings from October 2009

Re: What should \s \w \d match in 5.12?

Thread Previous | Thread Next
From:
Abigail
Date:
October 5, 2009 12:37
Subject:
Re: What should \s \w \d match in 5.12?
Message ID:
20091005193722.GB7980@almanda
On Mon, Oct 05, 2009 at 08:04:37PM +0100, John wrote:
>>   
> I would realy like to be able to do is somthing like this.
>
> my $str = 'garçon';
> use local 'fr';
> print "Contains french exemplar characters" if $string=~/^\w+$/;
> use local 'en';
> print "Contains non english exemplar characters" unless $string=~/^\w+$/;

You can do it this way, not having to depend on whatever may be installed
on the system:

sub French {return <<"--"}  # Might not be the correct set of French chars.
41 5A
61 7A
C0 C2
C6 CA
CC CE
D2 D4
E0 E2
E6 EA
EC EE
F2 F4
--

say "Contains French exemplar characters" if $string =~ /^\p{French}+$/;


Abigail

Thread Previous | 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