@@ -1510,9 +1510,12 @@ end
1510
1510
export lastindex
1511
1511
end
1512
1512
1513
- @static if VERSION < v " 0.7.0-DEV.3272"
1514
- import Base: in, findfirst, findnext, findlast, findprev
1515
-
1513
+ @static if VERSION >= v " 0.7.0-DEV.3272"
1514
+ findnext (xs... ) = Base. findnext (xs... )
1515
+ findfirst (xs... ) = Base. findfirst (xs... )
1516
+ findprev (xs... ) = Base. findprev (xs... )
1517
+ findlast (xs... ) = Base. findlast (xs... )
1518
+ else
1516
1519
struct OccursIn{T} <: Function
1517
1520
x:: T
1518
1521
@@ -1522,41 +1525,47 @@ end
1522
1525
const occursin = OccursIn
1523
1526
export occursin
1524
1527
1525
- zero2nothing (x) = x == 0 ? nothing : x
1528
+ zero2nothing (x:: Integer ) = x == 0 ? nothing : x
1529
+ zero2nothing (x) = x
1530
+
1531
+ findnext (xs... ) = zero2nothing (Base. findnext (xs... ))
1532
+ findfirst (xs... ) = zero2nothing (Base. findfirst (xs... ))
1533
+ findprev (xs... ) = zero2nothing (Base. findprev (xs... ))
1534
+ findlast (xs... ) = zero2nothing (Base. findlast (xs... ))
1526
1535
1527
- findnext (r:: Regex , s:: AbstractString , idx:: Integer ) = search (s, r, idx)
1528
- findfirst (r:: Regex , s:: AbstractString ) = search (s, r)
1529
- findnext (c:: EqualTo{Char} , s:: AbstractString , i:: Integer ) = zero2nothing ( search (s, c. x, i) )
1530
- findfirst (c:: EqualTo{Char} , s:: AbstractString ) = zero2nothing ( search (s, c. x) )
1531
- findnext (b:: EqualTo{<:Union{Int8,UInt8}} , a:: Vector{<:Union{Int8,UInt8}} , i:: Integer ) =
1532
- zero2nothing ( search (a, b. x, i) )
1533
- findfirst (b:: EqualTo{<:Union{Int8,UInt8}} , a:: Vector{<:Union{Int8,UInt8}} ) =
1534
- zero2nothing ( search (a, b. x) )
1536
+ Base . findnext (r:: Regex , s:: AbstractString , idx:: Integer ) = search (s, r, idx)
1537
+ Base . findfirst (r:: Regex , s:: AbstractString ) = search (s, r)
1538
+ Base . findnext (c:: EqualTo{Char} , s:: AbstractString , i:: Integer ) = search (s, c. x, i)
1539
+ Base . findfirst (c:: EqualTo{Char} , s:: AbstractString ) = search (s, c. x)
1540
+ Base . findnext (b:: EqualTo{<:Union{Int8,UInt8}} , a:: Vector{<:Union{Int8,UInt8}} , i:: Integer ) =
1541
+ search (a, b. x, i)
1542
+ Base . findfirst (b:: EqualTo{<:Union{Int8,UInt8}} , a:: Vector{<:Union{Int8,UInt8}} ) =
1543
+ search (a, b. x)
1535
1544
1536
- findnext (c:: OccursIn {<: Union{Tuple{Vararg{Char}},AbstractVector{Char},Set{Char}} },
1545
+ Base . findnext (c:: OccursIn {<: Union{Tuple{Vararg{Char}},AbstractVector{Char},Set{Char}} },
1537
1546
s:: AbstractString , i:: Integer ) =
1538
- zero2nothing ( search (s, c. x, i) )
1539
- findfirst (c:: OccursIn {<: Union{Tuple{Vararg{Char}},AbstractVector{Char},Set{Char}} },
1547
+ search (s, c. x, i)
1548
+ Base . findfirst (c:: OccursIn {<: Union{Tuple{Vararg{Char}},AbstractVector{Char},Set{Char}} },
1540
1549
s:: AbstractString ) =
1541
- zero2nothing ( search (s, c. x) )
1542
- findnext (t:: AbstractString , s:: AbstractString , i:: Integer ) = search (s, t, i)
1543
- findfirst (t:: AbstractString , s:: AbstractString ) = search (s, t)
1544
-
1545
- findfirst (delim:: EqualTo{UInt8} , buf:: IOBuffer ) = zero2nothing ( search (buf, delim. x) )
1546
-
1547
- findprev (c:: EqualTo{Char} , s:: AbstractString , i:: Integer ) = zero2nothing ( rsearch (s, c. x, i) )
1548
- findlast (c:: EqualTo{Char} , s:: AbstractString ) = zero2nothing ( rsearch (s, c. x) )
1549
- findprev (b:: EqualTo{<:Union{Int8,UInt8}} , a:: Vector{<:Union{Int8,UInt8}} , i:: Integer ) =
1550
- zero2nothing ( rsearch (a, b. x, i) )
1551
- findlast (b:: EqualTo{<:Union{Int8,UInt8}} , a:: Vector{<:Union{Int8,UInt8}} ) =
1552
- zero2nothing ( rsearch (a, b. x) )
1553
-
1554
- findprev (c:: OccursIn {<: Union{Tuple{Vararg{Char}},AbstractVector{Char},Set{Char}} },
1555
- s:: AbstractString , i:: Integer ) = zero2nothing ( rsearch (s, c. x, i) )
1556
- findlast (c:: OccursIn {<: Union{Tuple{Vararg{Char}},AbstractVector{Char},Set{Char}} },
1557
- s:: AbstractString ) = zero2nothing ( rsearch (s, c. x) )
1558
- findprev (t:: AbstractString , s:: AbstractString , i:: Integer ) = rsearch (s, t, i)
1559
- findlast (t:: AbstractString , s:: AbstractString ) = rsearch (s, t)
1550
+ search (s, c. x)
1551
+ Base . findnext (t:: AbstractString , s:: AbstractString , i:: Integer ) = search (s, t, i)
1552
+ Base . findfirst (t:: AbstractString , s:: AbstractString ) = search (s, t)
1553
+
1554
+ Base . findfirst (delim:: EqualTo{UInt8} , buf:: IOBuffer ) = search (buf, delim. x)
1555
+
1556
+ Base . findprev (c:: EqualTo{Char} , s:: AbstractString , i:: Integer ) = rsearch (s, c. x, i)
1557
+ Base . findlast (c:: EqualTo{Char} , s:: AbstractString ) = rsearch (s, c. x)
1558
+ Base . findprev (b:: EqualTo{<:Union{Int8,UInt8}} , a:: Vector{<:Union{Int8,UInt8}} , i:: Integer ) =
1559
+ rsearch (a, b. x, i)
1560
+ Base . findlast (b:: EqualTo{<:Union{Int8,UInt8}} , a:: Vector{<:Union{Int8,UInt8}} ) =
1561
+ rsearch (a, b. x)
1562
+
1563
+ Base . findprev (c:: OccursIn {<: Union{Tuple{Vararg{Char}},AbstractVector{Char},Set{Char}} },
1564
+ s:: AbstractString , i:: Integer ) = rsearch (s, c. x, i)
1565
+ Base . findlast (c:: OccursIn {<: Union{Tuple{Vararg{Char}},AbstractVector{Char},Set{Char}} },
1566
+ s:: AbstractString ) = rsearch (s, c. x)
1567
+ Base . findprev (t:: AbstractString , s:: AbstractString , i:: Integer ) = rsearch (s, t, i)
1568
+ Base . findlast (t:: AbstractString , s:: AbstractString ) = rsearch (s, t)
1560
1569
1561
1570
findall (b:: OccursIn , a) = findin (a, b. x)
1562
1571
# To fix ambiguity
0 commit comments