Hi @vasile-caraus, @peterjones, @alan-kilborn and All,
First, Alan I apologize because I forgot a part of a sentence, in my previous post ! I said :
It is said that .NET supports full regular expression syntax. So, you do not need the use of the \K feature ;-))
But I wanted to say :
It is said that .NET supports full regular expression syntax within look-behinds. So, you do not need the use of the \K feature ;-))
Indeed, using the examples of special look-behind constructions, given in :
https://www.regular-expressions.info/refadv.html
(?<=is|e)t matches the second and fourth letter t in the string twisty streets. This syntax should work with .NET and does not work with our Boost regex engine. Whereas the similar syntax (?<=is|ee)t, with alternatives of the same length, is correct with Boost !
(?<=s\w{1,7})t matches only the fourth letter t in the string twisty streets. This syntax should work with .NET and does not work with our Boost regex engine. Whereas the similar syntax (?<=s\w{4})t, , with a fix number of repetitions, is correct with Boost !
(?<=s\w+)t matches only the fourth letter t in the string twisty streets. This syntax should work with .NET and does not work with our Boost regex engine. Whereas the syntax s\w+\Kt, using the \K feature, is correct with Boost !
(\w).+(?<=\1), with a back-reference inside the look-behind, matches twisty street in the string twisty streets. This syntax should work with .NET and does not work with our Boost regex engine. Whereas the syntax (\w).+\1, without any look-behind feature, is, of course, correct with Boost !. In the both cases, assuming the implicit (?-s) modifier, it matches the longest zone of standard characters between a same starting and ending word character ! However, note a subtle difference :
With the .NET syntax, (\w).+(?<=\1), the .+ part matches the string wisty street
With the Boost syntax, (\w).+\1, the .+ part matches the string wisty stree
s\Kt, with the \K feature ( “Keep text out of the regex match” ), matches the second and third letter t in the string twisty streets. Seemingly, this syntax is not allowed in .NET regex engine but does work with our Boost regex engine ! Note that this example is trivial because we can use, instead, both with .NET and Boost, the regex (?<=s)t, which uses a simple look-behind structure ;-))
I hope, Alan, that these additional explanations will shed some light on this matter ;-))
Best Regards,
guy038