I wan’t to use a variable interpolation and a regex flag at the same time, is it possible ? For example
# if I wan to ignore to ignore case with a flag :
ERROR: UndefVarError: i not defined
 top-level scope at REPL:1
julia> r"StRinG"i # works but no string interpolation is possible
julia> Regex("(?i)$x") # also works in that case but the flag is part of the regex
You can give
"i" as the second argument to
Regex, as the documentation indicates:
search: Regex RegexMatch
A type representing a regular expression. Regex objects can be used to
match strings with match.
Regex objects can be created using the @r_str string macro. The
Regex(pattern[, flags]) constructor is usually used if the pattern string
needs to be interpolated. See the documentation of the string macro for
details on flags.
julia> Regex("StRinG", "i")
Thank you @pfitzseb ! I read the documentation here and this second argument was only mentioned for r" ".