From 3b8776866fd716174e444e9e522622723eda8a93 Mon Sep 17 00:00:00 2001 From: Alex Arslan Date: Fri, 2 Mar 2018 15:07:34 -0800 Subject: [PATCH] Deprecate callable Regex objects --- NEWS.md | 2 ++ base/deprecated.jl | 4 ++++ base/regex.jl | 2 -- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index c87f16568d9bb3..7554528836142b 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 b0db5a9bb231d9..7d71c04d2a35ce 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 f88192621476b8..d44c531477a56a 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]])