Andrew wrote:
> I am tying to expand some camel case with spaces - but I want multiple 
> captitals to remain as one word. So
> I want  "PerlNotesOnXML" -> "Perl Notes On XML"
> 
> My attempt is to use [A-Z]+ in a lookahead.
> 
>   my $text = "PerlNotesOnXML" ;
>   $text =~ s/(?=[A-Z]+)/ /gx ;
>   print $text ;
> 
> I think I can see what is happening - [A-Z]+ matches XML then ML then L.
> Is there a way of preventing it looking XML more than once.

I suggest

  $text =~ s/([^A-Z\s])([A-Z])/$1 $2/g;

which finds an upper case character which is preceded by a character which is
neither upper case nor whitespace and puts a space between them.

HTH,

Rob

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to