Skip to content

Commit

Permalink
MatchData: correct sample code for duplicated named capture
Browse files Browse the repository at this point in the history
  • Loading branch information
makenowjust committed Apr 4, 2018
1 parent ec423eb commit d34885a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/regex/match_data.cr
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class Regex
# matched capture group.
#
# ```
# "Crystal".match(/(?<ok>Cr)|(?<ok>al)/).not_nil!["ok"]? # => "al"
# "Crystal".match(/(?<ok>Cr).*(?<ok>al)/).not_nil!["ok"]? # => "al"
# ```
def []?(group_name : String)
max_start = -1
Expand All @@ -189,7 +189,7 @@ class Regex
# matched capture group.
#
# ```
# "Crystal".match(/(?<ok>Cr)|(?<ok>al)/).not_nil!["ok"] # => "al"
# "Crystal".match(/(?<ok>Cr).*(?<ok>al)/).not_nil!["ok"] # => "al"
# ```
def [](group_name : String)
match = self[group_name]?
Expand Down

0 comments on commit d34885a

Please sign in to comment.