From 80c9006a9a62a5b53de086d03c231f14b92e063a 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 2d6ff3ca59d31..b67bb8bcfe70f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1072,6 +1072,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 fe98c6e8bb707..b97e8234ac657 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -1455,6 +1455,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 e6f81bd74388e..8b327c0719711 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]])