Skip to content

Commit cb1feeb

Browse files
committed
Deprecate callable Regex objects
1 parent 0c1c815 commit cb1feeb

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
@@ -1069,6 +1069,8 @@ Deprecated or removed
10691069

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

1072+
* `Regex` objects are no longer callable. Use `isfound` instead ([#26283]).
1073+
10721074
* The methods of `range` based on positional arguments have been deprecated in favor of
10731075
keyword arguments ([#25896]).
10741076

base/deprecated.jl

+4
Original file line numberDiff line numberDiff line change
@@ -1457,6 +1457,10 @@ end
14571457
# PR #26283
14581458
@deprecate contains(haystack, needle) isfound(needle, haystack)
14591459
@deprecate contains(s::AbstractString, r::Regex, offset::Integer) isfound(r, s, offset=offset)
1460+
function (r::Regex)(s)
1461+
depwarn("`(r::Regex)(s)` is deprecated, use `isfound(r, s)` instead.", :Regex)
1462+
isfound(r, s)
1463+
end
14601464

14611465
# Issue #25786
14621466
@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)