Skip to content

Commit c21b14f

Browse files
committedMay 31, 2014
Merge pull request #7056 from porterjamesj/re-idx-doc
Document idx option to match.
2 parents 0f44abb + 8a116d7 commit c21b14f

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed
 

‎doc/manual/strings.rst

+14
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,20 @@ text after the comment character. We could do the following:
595595
julia> m = match(r"^\s*(?:#\s*(.*?)\s*$|$)", "# a comment ")
596596
RegexMatch("# a comment ", 1="a comment")
597597

598+
When calling ``match``, you have the option to specify an index at
599+
which to start the search. For example:
600+
601+
.. doctest::
602+
603+
julia> m = match(r"[0-9]","aaaa1aaaa2aaaa3",1)
604+
RegexMatch("1")
605+
606+
julia> m = match(r"[0-9]","aaaa1aaaa2aaaa3",6)
607+
RegexMatch("2")
608+
609+
julia> m = match(r"[0-9]","aaaa1aaaa2aaaa3",11)
610+
RegexMatch("3")
611+
598612
You can extract the following info from a ``RegexMatch`` object:
599613

600614
- the entire substring matched: ``m.match``

‎doc/stdlib/base.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1174,7 +1174,7 @@ Strings
11741174

11751175
.. function:: match(r::Regex, s::String[, idx::Integer[, addopts]])
11761176

1177-
Search for the first match of the regular expression ``r`` in ``s`` and return a RegexMatch object containing the match, or nothing if the match failed. The matching substring can be retrieved by accessing ``m.match`` and the captured sequences can be retrieved by accessing ``m.captures``
1177+
Search for the first match of the regular expression ``r`` in ``s`` and return a RegexMatch object containing the match, or nothing if the match failed. The matching substring can be retrieved by accessing ``m.match`` and the captured sequences can be retrieved by accessing ``m.captures`` The optional ``idx`` argument specifies an index at which to start the search.
11781178

11791179
.. function:: eachmatch(r::Regex, s::String[, overlap::Bool=false])
11801180

0 commit comments

Comments
 (0)
Please sign in to comment.