Ramprasad A Padmanabhan wrote:
Hi all,

Hello,

I want a regex to replace all continuous occurrences of '-' with
something else say 'x' except the first one


These are some examples

 "- Ram"     ===>             "- Ram"
 "-- bla"    ===>             "-x blah"
 "bla ---"   ===>             "bla -xxx"

And also
  "-- blah ---"     ===>      "-x blah -xx"

$ perl -le' my @x = ( "- Ram", "-- bla", "bla ---", "-- blah ---" ); for ( @x ) { print; s/(-)(-*)/ $1 . "x" x length $2 /eg; print; } ' - Ram - Ram -- bla -x bla bla --- bla -xx -- blah --- -x blah -xx



John
--
use Perl;
program
fulfillment

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




Reply via email to