diff --git a/NEWS.md b/NEWS.md index c87f16568d9bb..7554528836142 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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]). diff --git a/base/deprecated.jl b/base/deprecated.jl index b0db5a9bb231d..7d71c04d2a35c 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -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 diff --git a/base/regex.jl b/base/regex.jl index f88192621476b..d44c531477a56 100644 --- a/base/regex.jl +++ b/base/regex.jl @@ -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]])