Regular expressions

To search for and match patterns in text and other data, regular expressions are an indispensable tool for the data scientist. Julia adheres to the Perl syntax of regular expressions. For a complete reference, refer to http://www.regular-expressions.info/reference.html. Regular expressions are represented in Julia as a double (or triple) quoted string preceded by r, such as r"..." (optionally, followed by one or more of the i, s, m, or x flags), and they are of type Regex. The regexp.jl script shows some examples.

In the first example, we will match the email addresses (#> shows the result):

email_pattern = r".+@.+" 
input = "john.doe@mit.edu" 
println(occursin(email_pattern, input)) #> true 

The regular expression pattern ...

Get Julia 1.0 Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.