Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: can u suggest a regex for this ?

by Discipulus (Canon)
on Feb 03, 2023 at 15:49 UTC ( [id://11150132]=note: print w/replies, xml ) Need Help??


in reply to can u suggest a regex for this ?

Hello misterperl

also flip-flop can be used (look for the scalar context usage):

use strict; use warnings; while (<DATA>){ print /^cat/ .. /^\^cat/ ? "#$_" : $_; } __DATA__ mouse cat 1 2 3 ^cat deer eel cat furbaby elk ^cat dog fish

L*

PS ^\^ is actually a cat :)

PPS overlooked previous answer was already using flip-flop.. let rephrase: you can also use flip-flop directly :)

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-04-19 22:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found