Skip to content

Commit 466088d

Browse files
committed
add regex functions (fixes #55)
1 parent be1873b commit 466088d

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/LaTeXStrings.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,5 +127,8 @@ Base.isvalid(s::LaTeXString, i::Integer) = isvalid(s.s, i)
127127
Base.pointer(s::LaTeXString) = pointer(s.s)
128128
Base.IOBuffer(s::LaTeXString) = IOBuffer(s.s)
129129
Base.unsafe_convert(T::Union{Type{Ptr{UInt8}},Type{Ptr{Int8}},Cstring}, s::LaTeXString) = Base.unsafe_convert(T, s.s)
130+
Base.match(re::Regex, s::LaTeXString, idx::Integer, add_opts::UInt32=UInt32(0)) = match(re, s.s, idx, add_opts)
131+
Base.findnext(re::Regex, s::LaTeXString, idx::Integer) = findnext(re, s.s, idx)
132+
Base.eachmatch(re::Regex, s::LaTeXString; overlap = false) = eachmatch(re, s.s; overlap=overlap)
130133

131134
end # module

test/runtests.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ end
2222
@test L"foo"[1] == '$'
2323
@test tst1[1:2] == tst1[0x01:0x02] == tst1[[1,2]] == "an"
2424

25+
@test match(r"[a-z]+", tst1, 3).match == match(r"[a-z]+", tst1.s, 3).match
26+
@test findnext(r"[a-z]+", tst1, 3) == findnext(r"[a-z]+", tst1.s, 3)
27+
@test [m.match for m in eachmatch(r"[a-z]+", tst1)] == [m.match for m in eachmatch(r"[a-z]+", tst1.s)]
28+
2529
# issue #23 — will change if #17 is addressed
2630
@test L"x" * L"y" == "\$x\$\$y\$"
2731

0 commit comments

Comments
 (0)