I'm new to Regular Expressions in Ruby, and I can't seem to find any solid documentation on what \k<name+0>
means. It's the +0
part that I'm not getting.
Here's an example - this Regexp matches palindromes:
\A(?<p>(?:(?<l>\w)\g<p>\k<l+0>|\w))\z
When I remove the +0
in \k<l+0>
it no longer matches correctly.
My tests:
>> /\A(?<p>(?:(?<l>\w)\g<p>\k<l+0>|\w))\z/.match "aabbcdcbbaa"
#=> #<MatchData "aabbcdcbbaa" p:"aabbcdcbbaa" l:"c">
>> /\A(?<p>(?:(?<l>\w)\g<p>\k<l>|\w))\z/.match "aabbcdcbbaa"
#=> nil
All I've done is remove the +0
. I haven't yet found any documentation or example of this, can anyone point me in the right direction?