noshankus
asked on
Replace all instances of \ with /
Hello,
I'm trying to replace all the instances of \ with /.
I have tried doing:
$content =~ s/\///g;
and
$content =~ tr/\///;
and many various versions trying to escape by adding an extra \ or two!!
Can anyone let me know if it's possible?
Thank you for your help and hints!
Best regards,
I'm trying to replace all the instances of \ with /.
I have tried doing:
$content =~ s/\///g;
and
$content =~ tr/\///;
and many various versions trying to escape by adding an extra \ or two!!
Can anyone let me know if it's possible?
Thank you for your help and hints!
Best regards,
ASKER
Nope! Sorry... but you sure you got the right syntax?
I want to replace all \ with /
Those damn commands hurt my eyes!!
I want to replace all \ with /
Those damn commands hurt my eyes!!
ASKER
Nope! Sorry... but you sure you got the right syntax?
I want to replace all \ with /
Those damn commands hurt my eyes!!
I want to replace all \ with /
Those damn commands hurt my eyes!!
i just tested it in my system, it is working absolutely fine
just cut and copy what is given, it shld work
just cut and copy what is given, it shld work
ASKER
Damn! I was so hoping you were wrong! :)
It still doesn't work on my system. I just get a space instead.
The input is some\thing and when it does it's stuff, I get some thing.
I can't even test it on my local system, as I'm having to do this online through a free provider. - Maybe that has something to do with it... but all the other swaps worked. Damn!
Any other ideas how I might go about this? - Extra help appreciated :)
It still doesn't work on my system. I just get a space instead.
The input is some\thing and when it does it's stuff, I get some thing.
I can't even test it on my local system, as I'm having to do this online through a free provider. - Maybe that has something to do with it... but all the other swaps worked. Damn!
Any other ideas how I might go about this? - Extra help appreciated :)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
and that is the reason why you are getting spaces in your output and not \
ASKER
Oh I see.
Well, the problem is that the string could be quite long, as it's usually a path to a file:
some\thing\else\and\more\e tc.jsp
So, you are saying that if the string (which is being sent from a form text area) is too long, then it will recognise all the \'s as spaces?
How would I get around that? :)
Thanks for your time, I really appreciate it :)
Well, the problem is that the string could be quite long, as it's usually a path to a file:
some\thing\else\and\more\e
So, you are saying that if the string (which is being sent from a form text area) is too long, then it will recognise all the \'s as spaces?
How would I get around that? :)
Thanks for your time, I really appreciate it :)
ASKER
I just did another swap that swapped the spaces with /
LOL! You'd think it would be easier!
Anyway, thank you very much for your help!
LOL! You'd think it would be easier!
Anyway, thank you very much for your help!
Can you just give an idea of from where you are getting the text from, and can you just put a piece of code
ASKER
Much appreciated :)
Can you just give an idea of from where you are getting the text from, and can you just put a piece of code
Well if you would like it, what you can do is, when you are getting the test, if there is some way you can pass the text as
$content = "some\\value\\somewhere\\s omething";
then there would be no problem
$content = "some\\value\\somewhere\\s
then there would be no problem
hope it helps
$value =~ s/\//\\/g;