in reply to split and capitalize regex
This ucfirsts any character that doesn't follow a non-_. (The double-negative condition is a more terse way of saying "follows a _ or at the beginning of a string": s/(?:\A|(?<=_))(.)/ucfirst($1)/ge.)$c = "a_c_code"; $c =~ s/(?<![^_])(.)/ucfirst($1)/ge; print $c;
Why ucfirst instead of uc when only dealing with one character? Because there are ligature characters (the only latin1 instance being "\xdf") where the two produce different results.
|
|---|