tags:

views:

53

answers:

3

The original string is passed as:

FileSystems\/\1K-blocks=5036316, FileSystems\/\Available=3295944, FileSystems\/\Filesystem=/dev/cciss/c0d0p2, FileSystems\/\Use%=32%

What I need as an output is:

/ 1K-blocks=5036316, / Available=3295944, / Filesystem=/dev/cciss/c0d0p2, / Use%=32%

but trying to delete the '\' with a regex is giving me all kinds of headaches. I keep ending up with:

Fi eSys ems/☺K-b o ks=5036316  Fi eSys ems/Avai ab e=3295944  Fi eSys ems/Fi esy
s em=/dev/  iss/ 0d0p2  Fi eSys ems/SE%=32%  

Perl is apparently seeing it a a control or escape code and really screwing it up.

Any suggestions would be greatly appreciated.

A: 

These two lines should do it:

s/FileSystems\\//g;
s/\\/ /g;
bluesmoon
+3  A: 

I would use different delimiters (other than /) to make the regex a little easier on the eyes:

s!FileSystems\\/\\!/ !g
owst
A: 

owst has the right idea imo. Using diff. delimiters will make this much less confusing.

$line =~ s!FileSystem\\/\\!/\s!g

would do the trick

mcriech
You cannot use \s in the replacement string.
M42