-----Original Message-----
I have a string that has got

 1||||2||||3|4|||5 

What I need it in is

1|2|3|4|5

I have tried 

$string =~ s/\||/\|/g;

and i get this as a result

|1|||||2|||||3||4||||5|
---------------------------
Johnno,

I'll give you the two part answer:

1) Your regex matches one pipe, or "anything", because you didn't escape the
second pipe character.
2) Try s/\|+/\|/g.  The plus searches for one or more, and then replacement
is just one.

Chris


LEGAL NOTICE
Unless expressly stated otherwise, this message is confidential and may be privileged. 
It is intended for the addressee(s) only. Access to this E-mail by anyone else is 
unauthorized. If you are not an addressee, any disclosure or copying of the contents 
of this E-mail or any action taken (or not taken) in reliance on it is unauthorized 
and may be unlawful. If you are not an addressee, please inform the sender immediately.
_______________________________________________
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to