CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
how to extract everthing else from a string after a pattern

 



cliffyiu
Novice

May 7, 2012, 8:47 AM

Post #1 of 2 (991 views)
how to extract everthing else from a string after a pattern Can't Post

Hi,

I have a file containing the following lines:

abcd;dfasdgf;name=sfadf;sdfasdf
ahd;name=sdfd;dfdfa

I want to extract the strings after the pattern "name=" and get the following lines:

sfadf;sdfasdf
sdfd;dfdfa

Anyone knows how to do that? I know regulation expression may work for this but I just can't figure out the right expression..

Thanks


wickedxter
User

May 8, 2012, 6:12 PM

Post #2 of 2 (778 views)
Re: [cliffyiu] how to extract everthing else from a string after a pattern [In reply to] Can't Post

you capture it with ()


Code
 
use strict;
use feature qw(say);

my $string = "abcd;dfasdgf;name=sfadf;sdfasdf
ahd;name=sdfd;dfdfa ";

my @match = map{ /name=(.*)/g } $string;

for (@match){
say $_;
}


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives