Skip to content

Commit 80c9006

Browse files
committed
Deprecate callable Regex objects
1 parent 1eb6bfd commit 80c9006

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

NEWS.md

+2
Original file line numberDiff line numberDiff line change
@@ -1072,6 +1072,8 @@ Deprecated or removed
10721072

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

1075+
* `Regex` objects are no longer callable. Use `isfound` instead ([#26283]).
1076+
10751077
* The methods of `range` based on positional arguments have been deprecated in favor of
10761078
keyword arguments ([#25896]).
10771079

base/deprecated.jl

+4
Original file line numberDiff line numberDiff line change
@@ -1455,6 +1455,10 @@ end
14551455
# PR #26283
14561456
@deprecate contains(haystack, needle) isfound(needle, haystack)
14571457
@deprecate contains(s::AbstractString, r::Regex, offset::Integer) isfound(r, s, offset=offset)
1458+
function (r::Regex)(s)
1459+
depwarn("`(r::Regex)(s)` is deprecated, use `isfound(r, s)` instead.", :Regex)
1460+
isfound(r, s)
1461+
end
14581462

14591463
# Issue #25786
14601464
@deprecate_binding DevNull devnull

base/regex.jl

-2
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,6 @@ function isfound(r::Regex, s::SubString; offset::Integer=0)
153153
r.match_data)
154154
end
155155

156-
(r::Regex)(s) = isfound(r, s)
157-
158156
"""
159157
match(r::Regex, s::AbstractString[, idx::Integer[, addopts]])
160158

0 commit comments

Comments
 (0)