What @jling is saying is you need escaping, and note you could have done it this way r"^\\s*text"
but note also, instead of needing escaping (for regular strings) you can use the raw type, like raw"^\s*text"
That gives you a string, not a Regex, so you would still need Regex(raw"^\s*text") to make it so. That can help if you would otherwise need lots of escaping.
This got me thinking (since the r and raw strings are implemented by macros, r_str and raw_str), can you do macro composition (or here for string-types, so indirectly)?
râraw"^\s*text"
doesnât work (and maybe it shouldnâtâŚ), nor does (râraw)"^\s*text"
. Iâm ok with not having the option, since itâs likely very rare to doâŚ
but it got me thinking, should this have been the default for Juliaâs regexes, or at least also be provided?
A r_raw type of regex/string (or rather name it raw_r?) could be made. Iâm a bit stumped how. The former is implemented like:
macro r_str(pattern, flags...) Regex(pattern, flags...) end
and raw by:
macro raw_str(s); s; end
Note, PCRE is the regex engine (from Perl) library used in Julia, so the error comes from it, since something wrong with your regex, seemingly this (since Julia is 1-based, should mean the same as âoffset 0â there)::
I didnât read carefully, but it seems your fix may be as simple as r"^[[:space:]]*text"
in a sense needing a type of intentional âescapingâ, if you will).