Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Replacing between patterns

by jwkrahn (Abbot)
on Oct 28, 2019 at 20:34 UTC ( [id://11108056]=note: print w/replies, xml ) Need Help??


in reply to Replacing between patterns

$ echo "123 ABC 123 abc XYZ hi la" | perl -0777pe 's/ABC(?s:.*?)XYZ.*/[DATA]/' 123 [DATA] la

Replies are listed 'Best First'.
Re^2: Replacing between patterns
by rsFalse (Chaplain) on Oct 29, 2019 at 13:25 UTC
    Similarly, but with /m and $:
    echo "123 ABC 123 abc XYZ hi la" | perl -0777 -pe 's/ ABC .*? XYZ .*? $ /[DATA]/msx' 123 [DATA] la

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (1)
As of 2024-04-25 00:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found