http://www.perlmonks.org?node_id=1036140


in reply to Exception from a character class

perlunicode#User Defined Character Properties

#!/usr/bin/perl -- use strict; use warnings; use Data::Dump; Main( @ARGV ); exit( 0 ); sub Main { my $wa = "'I' am with \x{2018}two\x{2018} kinds of quotes"; my $wi = $wa; my $subs = int $wi =~ s{\p{Punct}}{-}g ; dd [ 'Punct ', $subs, $wa, $wi ]; $wi = $wa; $subs = int $wi =~ s{\p{InPunctNoApostrophe}}{-}g ; dd ['InPunctNoApostrophe', $subs, $wa, $wi ]; } sub InPunctNoApostrophe { return join "\n", ,'+utf8::Punct' ## \p{Punct} aka General_Punctuation ,'-2018' ## LEFT SINGLE QUOTATION MARK (U+2018) ,'-2019' ## RIGHT SINGLE QUOTATION MARK (U+2019) ,'-201A' ## SINGLE LOW .'-9 QUOTATION MARK (U+201A) ,'-201B' ## SINGLE HIGH .'-REVERSED .'-9 QUOTATION MA +RK (U+201B) ,'-201C' ## LEFT DOUBLE QUOTATION MARK (U+201C) ,'-201D' ## RIGHT DOUBLE QUOTATION MARK (U+201D) ,'-201E' ## DOUBLE LOW .'-9 QUOTATION MARK (U+201E) ,'-201F' ## DOUBLE HIGH .'-REVERSED .'-9 QUOTATION MA +RK (U+201F) ,'-2039' ## SINGLE LEFT .'-POINTING ANGLE QUOTATION MARK + (U+2039) ,'-203A' ## SINGLE RIGHT .'-POINTING ANGLE QUOTATION MAR +K (U+203A) #~ ,'-0027' ## ascii https://en.wikipedia.org/wiki/Apostrop +he } __END__ [ "Punct ", 4, "'I' am with \x{2018}two\x{2018} kinds of quotes", "-I- am with -two- kinds of quotes", ] [ "InPunctNoApostrophe", 2, "'I' am with \x{2018}two\x{2018} kinds of quotes", "-I- am with \x{2018}two\x{2018} kinds of quotes", ]
  • Comment on Re: Exception from a character class (user defined character properties \p{IsUserDefined} sub IsUserDefined )
  • Download Code