Julia Language Regex literals


Julia supports regular expressions1. The PCRE library is used as the regex implementation. Regexes are like a mini-language within a language. Since most languages and many text editors provide some support for regex, documentation and examples of how to use regex in general are outside the scope of this example.

It is possible to construct a Regex from a string using the constructor:

julia> Regex("(cat|dog)s?")

But for convenience and easier escaping, the @r_str string macro can be used instead:

julia> r"(cat|dog)s?"

1: Technically, Julia supports regexes, which are distinct from and more powerful than what are called regular expressions in language theory. Frequently, the term "regular expression" will be used to refer to regexes also.