From 1699438e4e7c2c4c5ba23989e6f9602f1b8cf145 Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Fri, 12 Jan 2018 22:17:27 +0100 Subject: [PATCH] add contains(str, r::Regex) (#452) --- README.md | 3 +++ src/Compat.jl | 5 +++++ test/runtests.jl | 3 +++ 3 files changed, 11 insertions(+) diff --git a/README.md b/README.md index c5e7b8bd15ca4..31c4cb9ae6ee9 100644 --- a/README.md +++ b/README.md @@ -278,6 +278,8 @@ Currently, the `@compat` macro supports the following syntaxes: * `copy!` and `unsafe_copy!` are now `copyto!` and `unsafe_copyto!` ([#24808]). +* `ismatch(r::Regex, str::AbstractString)` is now `contains(str, r)` ([#24673]). + * `ipermute!` is now `invpermute!` ([#25168]). ## New macros @@ -429,6 +431,7 @@ includes this fix. Find the minimum version from there. [#24648]: https://github.com/JuliaLang/julia/issues/24648 [#24652]: https://github.com/JuliaLang/julia/issues/24652 [#24657]: https://github.com/JuliaLang/julia/issues/24657 +[#24673]: https://github.com/JuliaLang/julia/issues/24673 [#24714]: https://github.com/JuliaLang/julia/issues/24714 [#24785]: https://github.com/JuliaLang/julia/issues/24785 [#24808]: https://github.com/JuliaLang/julia/issues/24808 diff --git a/src/Compat.jl b/src/Compat.jl index 694b46a69685b..2c178877aa782 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -1093,6 +1093,11 @@ end export copyto!, unsafe_copyto! end +# 0.7.0-DEV.3272 +@static if VERSION < v"0.7.0-DEV.3272" + Base.contains(str::AbstractString, r::Regex) = ismatch(r, str) +end + @static if VERSION < v"0.7.0-DEV.3025" import Base: convert, ndims, getindex, size, length, eltype, start, next, done, first, last diff --git a/test/runtests.jl b/test/runtests.jl index 8a4572cde5617..842c435f9ba09 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1083,6 +1083,9 @@ let A = [0, 0, 0], B = [1, 2, 3] @test unsafe_copyto!(A, 2, B, 1, 1) === A == [0, 1, 0] end +# 0.7 +@test contains("Hello, World!", r"World") + # 0.7.0-DEV.3173 @test invpermute!(permute!([1, 2], 2:-1:1), 2:-1:1) == [1, 2]