Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Regex to find repeated patterns

by mjscott2702 (Pilgrim)
on Nov 18, 2010 at 09:47 UTC ( #872173=note: print w/replies, xml ) Need Help??


in reply to Regex to find repeated patterns

Hmmm, as Corion has pointed out, you'll get much better response by showing what you have tried, and in what way it fails.

That being said, does this code do what you are looking for?

use strict; use warnings; my $str = "*L*Name1*L*Name2*L**D*Place1*D*Place2*D**L*Name3*L*"; my @names =$str =~ m/\*L\*(\w+)/g; print "@names\n"; $str =~ s/\*L\*$names[0]//; print "Modified string = $str\n";

Output:

Name1 Name2 Name3
Modified string = *L*Name2*L**D*Place1*D*Place2*D**L*Name3*L*

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://872173]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2017-04-28 06:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (519 votes). Check out past polls.