Project

General

Profile

Actions

Bug #14500

closed

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

Added by Sundeep (Sundeep Agarwal) about 6 years ago. Updated over 2 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[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

Like0
Like0Like0Like0Like0Like0