I have seen in some examples \K like here "Replace by an "X" every 3rd character in a string PHP", but I don't quite understand what exactly it is needed for and I can't find absolutely any information on the web. Can you shed some light?
Asked
Active
Viewed 26 times
0
-
2See https://www.regular-expressions.info/keep.html and https://www.rexegg.com/regex-best-trick.html#bsk – Wiktor Stribiżew Jun 01 '22 at 07:36
-
1@WiktorStribiżew So \K just discards the part from the match that is before \K, did I understand it correctly? – Verdant Jun 01 '22 at 07:43
-
2Yes, it is a kind of a "lookbehind equivalent". Also, see https://perldoc.perl.org/perlre#%5CK – Wiktor Stribiżew Jun 01 '22 at 07:44