Project

General

Profile

Actions

Misc #14500

open

Missing Regexp documentation and clarification on behavior of \K for edge case

Added by Sundeep (Sundeep Agarwal) over 3 years ago. Updated over 3 years ago.

Status:
Open
Priority:
Normal
Assignee:
-
[ruby-core:85707]

Description

Capturing section (https://ruby-doc.org/core-2.5.0/Regexp.html#class-Regexp-label-Capturing)

Anchors section (https://ruby-doc.org/core-2.5.0/Regexp.html#class-Regexp-label-Anchors)

  • suggestion to add documentation on \K
  • need clarification if the below behavior seen is expected and mention it while adding documentation
$ echo 'aaa' | ruby -pe 'gsub(/a\K/, ":")'
a:aa:

$ # what I expected
$ echo 'aaa' | ruby -pe 'gsub(/(a)/, "\\1:")'
a:a:a:
Actions

Also available in: Atom PDF