RE: [Perl-unix-users] Some help with strings

2004-04-05 Thread Elston, Jeremy
It looks like you just forgot to escape one of your pipes, but I would use translate myself. Should be more efficient. $string =~ tr[|][|]s; To (s)queeze out the extra characters. Jeremy Elston Sr. Staff Unix System Administrator Charles Schwab & Co., Inc. "The Jim Conspiracy IS real! You

RE: [Perl-unix-users] Some help with strings

2004-04-05 Thread Gerber, Christopher J
-Original Message- I have a string that has got 123|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||45| --- Johnno, I'll give you the two part answer: 1) Your regex matches on

RE: [Perl-unix-users] Some help with strings

2004-04-05 Thread Matt Schneider
I think what you are looking for is: $string =~ s/\|+/\|/g; Matthew Schneider System Administrator / Programmer SKLD Information Services, LLC 303.820.0863 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Johnno Sent: Monday, April 05, 2004 8:46 AM To: [EMA

Re: [Perl-unix-users] Some help with strings

2004-04-05 Thread Kester Allen
Hi Johnno-- You can use '+' in a regex to mean 'one-or-more', so s/\|+/|/ would mean "replace one or more pipe with a single pipe" (you don't need to escape the pipe in the replacement string). As a style matter, you can enclose the pipe in a chacter class with []s to make it easier to read:

RE: [Perl-unix-users] Some help with strings

2004-04-05 Thread Stacy Doss
Your RE $string =~ s/\||/\|/g; First the second pipe is not escaped so it maintains its "or-ness" So the match part of your RE is backslash or nothing (or null/nil if you like) nil matches before and after each real character, for the matches or backslash you're simply substituting backslash Try

RE: [Perl-unix-users] Some help with strings

2004-04-05 Thread James Schappet
This is what you want: #!/usr/bin/perl $STRING = "123|4|||5"; $STRING =~ s/\|+/|/g; print "$STRING\n"; =+=+=+=+=+=+=+=+=+=+ James Schappet Schappet.com -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Johnno Sent: Monday, April 05, 2004 10:46