Skip to content

Commit

Permalink
add contains(str, r::Regex) (#452)
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikekre authored Jan 12, 2018
1 parent 36d879c commit 1699438
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down

0 comments on commit 1699438

Please sign in to comment.