Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Need to pull substring between two escape sequences.

by indigo (Scribe)
on Mar 30, 2001 at 05:41 UTC ( #68258=note: print w/replies, xml ) Need Help??


in reply to Need to pull substring between two escape sequences.

Assuming your string isn't perverse (like having an escaped '#!' as part of the string literal):

my @matches = ($string =~ /!#(.*?)#!/g);

The .*? insures non-greedy matching and the /g applies it across the entire string. The params "capture" your string, and a list of all matching strings will be returned.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://68258]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2020-10-27 07:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (256 votes). Check out past polls.

    Notices?