r"..."是用于定义正则表达式的Julia 语法,只要需要正则表达式,就会在整个语言中使用(不仅仅是在数据帧中)。r""您可以通过在 Julia REPL 的内置帮助中搜索来找到有关此语法的更多信息:
help?> r""\n @r_str -> Regex\n\n Construct a regex, such as r"^[a-z]*$", without interpolation and unescaping (except\n for quotation mark " which still has to be escaped). The regex also accepts one or\n more flags, listed after the ending quote, to change its behaviour:\n\n \xe2\x80\xa2 i enables case-insensitive matching\n\n \xe2\x80\xa2 m treats the ^ and $ tokens as matching the start and end of individual\n lines, as opposed to the whole string.\n\n \xe2\x80\xa2 s allows the . modifier to match newlines.\n\n \xe2\x80\xa2 x enables "comment mode": whitespace is enabled except when escaped with \\,\n and # is treated as starting a comment.\n\n \xe2\x80\xa2 a disables UCP mode (enables ASCII mode). By default \\B, \\b, \\D, \\d, \\S, \\s,\n \\W, \\w, etc. match based on Unicode character properties. With this option,\n these sequences only match ASCII characters.\n\n See Regex if interpolation is needed.\n\n Examples\n \xe2\x89\xa1\xe2\x89\xa1\xe2\x89\xa1\xe2\x89\xa1\xe2\x89\xa1\xe2\x89\xa1\xe2\x89\xa1\xe2\x89\xa1\xe2\x89\xa1\xe2\x89\xa1\n\n julia> match(r"a+.*b+.*?d$"ism, "Goodbye,\\nOh, angry,\\nBad world\\n")\n RegexMatch("angry,\\nBad world")\n\n This regex has the first three flags enabled.\nRun Code Online (Sandbox Code Playgroud)\n更广泛地说,紧邻引号之前/并置的某些单词或字母的模式称为字符串宏(或非标准字符串文字),您甚至可以定义自己的模式(如在这样的包中)。该r"..."语法恰好是内置的,专门用于定义 regexp 对象,稍后可以使用 和 等函数将其应用于一个或多个match字符串replace。