note04
regex = r"H.*w"
m = match(regex, "I love Halloween!")
if isnothing(m)
println("no match")
else
println(m.match) #Get the matched string
println(m.offset) #Get the matched position
end
Regular expressions use the PCRE library. Prepend r to the string to indicate that it is a regular expression.
If it doesn't match the regular expression, the match function returns nothing. Use the isnothing () function to determine nothing.
If there is a match, an object of type RegexMatch is returned. You can get information such as matching strings and positions.
◆ Get the matched string ◆ Get the matched position
Julia Quick Look Note [01] How to use variables and constants Julia Quick Look Note [02] Arithmetic Expressions, Operators [Julia Quick Note [03] Complex Numbers] (https://qiita.com/ttabata/items/225c77a4d71fafc3e482) Julia Quick Look Note [04] Regular Expression [Julia quick note [05] if statement] (https://qiita.com/ttabata/items/4f0bcff1e32f60402dfb)
(* We will continue to increase the content)
: paperclip: Julia --Official page https://julialang.org/
: paperclip: Julia --Japanese official document https://julia-doc-ja.readthedocs.io/ja/latest/index.html
: paperclip: First time Julia and installation (Windows & Linux) https://qiita.com/ttlabo/items/b05bb43d06239f968035
:paperclip: Julia - Mathematics https://docs.julialang.org/en/v1/base/math/
If you have any opinions or corrections, please let us know.
Recommended Posts