Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Practical use cases for \K in regex

by jo37 (Deacon)
on Oct 05, 2023 at 17:08 UTC ( [id://11154832] : note . print w/replies, xml ) Need Help??


in reply to Practical use cases for \K in regex

Variable look-behind-assertions were not available before 5.30. IMHO it makes no sense to combine a look-behind-assertion with \K.
\K comes handy in cases like

echo fooooobar | perl -pe 's/fo{2,}ba\Kr/z/'

Greetings,
-jo

$gryYup$d0ylprbpriprrYpkJl2xyl~rzg??P~5lp2hyl0p$