Regular Expressions

Boo has built-in support for regular expression literals.

You surround the regular expression with / /,

  or @/ / for more complex expressions that contain whitespace.

 Boo even has an =~ operator like Perl.

Here are some samples of using regular expressions in boo:

Specifying regex options

One limitation of using built-in support for regular expressions is that you can't use non-standard regex options like regex compiled.

Actually there is a way to use the ignore case option. Add a (?i) to the beginnning of your regex pattern like so:

But in other cases you may want to just use the .NET Regex class explicitly:

Regex Replace method

This would be an equivalent to using perl's switch/replace statement: s/foo/bar/g.

regex primitive type

Also note, Boo has a built-in primitive type called "regex" (lowercase) that means the same thing as the .NET Regex class. So you can do for example:

See also:

Powered by Atlassian Confluence