Ricardo Pichler wrote:
Hi...
I need replace in my string the characters in
upperCase for the same but preceding the simbol +.

Ex.:
$myName="RicardoPichler";
s/.../.../g; # to do this return "+Ricardo+Pichler";

but like this:
$myName=~s/[A-Z]/\+[A-Z]/g;
but this donīt work.


You are attempting to use a character class as a replacement string which you don't want to do.... You would need something such as:


my $string = 'RicardoPichler';
$string =~ s/([A-Z])/\+$1/g;

This uses "capturing parentheses" to catch the character you want, in this case anything in the upper cased character class and replace it with a plus sign followed by the result of the first set of capturing parenthesis.

perldoc perlretut
perldoc perlre
perldoc perlvar

http://danconia.org


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to