RosettaCodeData/Task/String-matching/Julia/string-matching.julia

8 lines
434 B
Text
Raw Permalink Normal View History

2019-09-12 10:33:56 -07:00
startswith("abcd","ab") #returns true
findfirst("ab", "abcd") #returns 1:2, indices range where string was found
endswith("abcd","zn") #returns false
match(r"ab","abcd") != Nothing #returns true where 1st arg is regex string
for r in eachmatch(r"ab","abab")
2013-04-10 21:29:02 -07:00
println(r.offset)
2019-09-12 10:33:56 -07:00
end #returns 1, then 3 matching the two starting indices where the substring was found