Skip to content

Commit

Permalink
Deprecate callable Regex objects
Browse files Browse the repository at this point in the history
  • Loading branch information
ararslan committed Mar 3, 2018
1 parent 3b103fd commit ea55930
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,8 @@ Deprecated or removed

* `contains` has been deprecated in favor of a more general `isfound` function ([#26283]).

* `Regex` objects are no longer callable. Use `isfound` instead ([#26283]).

* The methods of `range` based on positional arguments have been deprecated in favor of
keyword arguments ([#25896]).

Expand Down
4 changes: 4 additions & 0 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1457,6 +1457,10 @@ end
# PR #26283
@deprecate contains(haystack, needle) isfound(needle, haystack)
@deprecate contains(s::AbstractString, r::Regex, offset::Integer) isfound(r, s, offset=offset)
function (r::Regex)(s)
depwarn("`(r::Regex)(s)` is deprecated, use `isfound(r, s)` instead.", :Regex)
isfound(r, s)
end

# Issue #25786
@deprecate_binding DevNull devnull
Expand Down
2 changes: 0 additions & 2 deletions base/regex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,6 @@ function isfound(r::Regex, s::SubString; offset::Integer=0)
r.match_data)
end

(r::Regex)(s) = isfound(r, s)

"""
match(r::Regex, s::AbstractString[, idx::Integer[, addopts]])
Expand Down

0 comments on commit ea55930

Please sign in to comment.