LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   perl regexp problem (https://www.linuxquestions.org/questions/programming-9/perl-regexp-problem-160596/)

raven 03-21-2004 12:28 PM

perl regexp problem
 
hello

i have a question in perl

lets say for example that I have the string with substrings "/:" in it (multiple occurances are possible). Now I want to extract these and replace them with something else (let's say with "...") how can I do that? I tried: $var=~y/\/:/\n/s; but this replaces every "/" only, and thats not what I wanted...

Any idea?

Thanks

raven

infamous41md 03-21-2004 02:21 PM

Code:

[n00b@localho.outernet] cat test.pl
#!/usr/bin/perl


$var = 'bla foo /:';

$var =~ s#/:#a#g;

print "$var\n";
[n00b@localho.outernet] ./test.pl
bla foo a

im no perl whiz, but this seems to work.

raven 03-21-2004 06:08 PM

yes, it did work, thanks alot. where was this kinda stuff documented? I read trough a few doc, but did not find *this* one...

raven

infamous41md 03-21-2004 06:10 PM

well, i know u can use anything as teh separator of reg-ex's, but i think iread that in some deitel book a while go

aluser 03-21-2004 11:49 PM

Code:

perldoc perlrequick
perldoc perlretut
perldoc perlre

:) I got those from "perldoc perl"


All times are GMT -5. The time now is 12:21 AM.