Version: v0.7.0 - Beta.  We welcome contributors & feedback.


A regex (regular expression) is a way to find and replace using a pattern.

The syntax can look confusing at first, but it is very powerful and flexible.

Regex strings are prefixed with a lowercase 'r'. (e.g. r'abc').

$pattern = r'(orange|red|yellow)'
'large red hoodie'.contains($pattern)
//= true

// Match one or more digits
'The number is: 123'.match(r'\d+')
//= '123'

// Match one or more word characters (a-z)
'abc 123'.match(r'\w+')
//= 'abc'

// Match one or more characters of
// lowercase 'a' through 'f'
'ID: 123-456-edca'.match(r'[a-f]+')
//= 'edca'

// Ignore case ('i' suffix)
'Hi, I`m Bea Goode'.match(r'[a-f]+'i)
//= 'Bea'

// Create a Regex from a regular string
$pattern = Regex('\\d+ \\w+', 'i')

See Also