LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 03-21-2004, 12:28 PM   #1
raven
Member
 
Registered: Dec 2001
Location: Basel, Switzerland
Distribution: ubuntu
Posts: 297

Rep: Reputation: 30
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
 
Old 03-21-2004, 02:21 PM   #2
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
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.
 
Old 03-21-2004, 06:08 PM   #3
raven
Member
 
Registered: Dec 2001
Location: Basel, Switzerland
Distribution: ubuntu
Posts: 297

Original Poster
Rep: Reputation: 30
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
 
Old 03-21-2004, 06:10 PM   #4
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
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
 
Old 03-21-2004, 11:49 PM   #5
aluser
Member
 
Registered: Mar 2004
Location: Massachusetts
Distribution: Debian
Posts: 557

Rep: Reputation: 42
Code:
perldoc perlrequick
perldoc perlretut
perldoc perlre
I got those from "perldoc perl"
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Regexp problem eremit Programming 6 06-23-2005 06:48 AM
Perl Regexp search-n-replace jpbarto Programming 2 06-16-2005 12:45 PM
Perl/regexp help... - query string parsing... lowpro2k3 Programming 4 05-11-2005 05:18 PM
PHP regexp problem abdul_zu Linux - Software 2 04-03-2005 07:35 AM
perl simple regexp champ Programming 3 07-07-2004 03:27 AM


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

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration