Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

phpmyadmin fehler rechte unerlaubte mischung, WWWXXXApc, lilo trying to map files from unnamed device 0x0000", Wwwxxxapc, CAM::PDF::Renderer::TextF Fragen, adodb.recordset error '800a0cc1', php save mails as eml, WWWXXXAPC, sqlexpress database file auto-creation error, sqlexpress database file auto-creation error

Links

XODOX
Impressum
Datenschutz

#1: Stop sent the mail to me

Posted on 2011-10-07 12:22:17 by ganesh vignesh

Stop the mail

On 10/7/11, Marc <sono-io@fannullone.us> wrote:
> On Sep 8, 2011, at 10:13 AM, Rob Dixon wrote:
>
>> my $string =3D 'The Kcl Group';
>>
>> $string =3D~ s/\b([aeiouy]{3,4}|[^aeiouy]{3,4})\b/\U$1/ig;
>>
>> print $string, "\n";
>
> I'd like to revisit this, if I could. I've modified the above regex so =
as
> not to capitalize ordinal numbers, however I've noticed that it produces
> incorrect output if the word has an apostrophe. Given:
>
> my $string =3D "rex's chicken on 51st st. at lkj";
> $string =3D~ s/\b([aeiouy]{3,4}|[^aeiouy0123456789]{3,4})\b/uc($1)/eg;
>
> the output is:
> Rex'S Chicken on 51st ST. at LKJ
>
> It should be:
> Rex's Chicken on 51st St. at LKJ
>
> I Googled and tried everything I'd found, but I can't fix it. Again, th=
at
> line should capitalize 3 and 4 letter words that have either all vowels o=
r
> all capitals. The code I found below works great for capitalization exce=
pt
> for that one regex which throws a wrench into it.
>
> Thanks,
> Marc
>
> -----------
>
> # http://daringfireball.net/2008/08/title_case_update
>
> use strict;
> use warnings;
> use utf8;
> use open qw( :encoding(UTF-8) :std );
>
>
> my @small_words =3D qw( (?<!q&)a an and as at(?!&t) but by en for if in o=
f on
> or the to v[.]? via vs[.]? );
> my $small_re =3D join '|', @small_words;
>
> my $apos =3D qr/ (?: ['â€=99] [[:lower:]]* )? /x;
>
> my $string =3D "rex's chicken on 51st st at lkj";
>
> $string =3D~
> s{
> \b (_*) (?:
> ( [-_[:alpha:]]+ [@.:/] [-_[:alpha:]@.:/]+ $apos ) # URL, domain, or
> email
> |
> ( (?i: $small_re ) $apos ) # or small word
> (case-insensitive)
> |
> ( [[:alpha:]] [[:lower:]'â€=99()\[\]{}]* $apos ) # or word w/o=
internal
> caps
> |
> ( [[:alpha:]] [[:alpha:]'â€=99()\[\]{}]* $apos ) # or some oth=
er word
> ) (_*) \b
> }{
> $1 . (
> defined $2 ? $2 # preserve URL, domain, or email
> : defined $3 ? "\L$3" # lowercase small word
> : defined $4 ? "\u\L$4" # capitalize word w/o internal caps
> : $5 # preserve other kinds of word
> ) . $6
> }exgo;
>
> $string =3D~
> # exceptions for small words: capitalize at start and end of title
> s{
> ( \A [[:punct:]]* # start of title...
> | [:.;?!][ ]+ # or of subsentence...
> | [ ]['"“‘(\[][ ]* ) # or of inserted subphrase...
> ( $small_re ) \b # ... followed by small word
> }{
> $1\u\L$2
> }xigo;
>
> $string =3D~
> s{
> \b ( $small_re ) # small word...
> (?=3D [[:punct:]]* \Z # ... at the end of the title...
> | ['"’â=80 )\]] [ ] ) # ... or of an inserted subphrase?
> }{
> \u\L$1
> }xigo;
>
> $string =3D~ s/\b([aeiouy]{3,4}|[^aeiouy0123456789]{3,4})\b/uc($1)/eg;
>
> print "$string \n";
> print "$string \n";
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> http://learn.perl.org/
>
>
>

--=20
Sent from my mobile device

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Report this message