Regex module
This module provides functions to interface to libpcre (perl-compatible regular expressions) for constructing and matching with regular expressions.
Regular expression support is provided by the PCRE library package, which is open source software, written by Philip Hazel, and copyright by the University of Cambridge, England.
The pcrepattern or perlre manual pages explain the regular expression syntax in detail.
Data types
- Regex::Match - Match object.
- Regex::REFlags - Flags for regular expression compilation
- Regex::Regex - Compiled regular expression
- Regex::ReplaceFlags - Replacement options
Exceptions
- NoUTF8Support - UTF-8 support unavailable
- RegexCompilationFailed - The regular expression could not be compiled.
Functions
- Regex compile(String pattern,[REFlags] fl=createArray(1)) - Compile a regular expression
- Int count(Regex patt,String str) - Count occurrences of a regular expression in a string.
- [String] grep(String patt,[String] xs,Bool inverse=false) - Search for patterns.
- Match match(Regex x,String str) - Attempt to match a regular expression.
- Match matchOnly(Regex x,String str) - Attempt to match a regular expression.
- Bool quickMatch(Regex re,String str) - Test a String with a compiled regular expression.
- Bool quickMatch(String patt,String str,[REFlags] fl=createArray(1)) - Test whether a string matches the pattern
- Void replace(Regex keyre,String new,var String str,[ReplaceFlags] fl=createArray(1)) - Replace a compiled pattern with a string.
- Void replace(String key,String new,var String str,[ReplaceFlags] fl=createArray(1),[REFlags] mfl=createArray(1)) - Replace a pattern with a string.
- String replaced(Regex keyre,String new,String str,[ReplaceFlags] fl=createArray(1)) - Replace a compiled pattern with a string.
- String replaced(String key,String new,String str,[ReplaceFlags] fl=createArray(1),[REFlags] mfl=createArray(1)) - Replace a compiled pattern with a string.
- [String] split(Regex pattre,String origstr,Int limit=0,Bool allowempty=false) - Split a string into substrings.
- [String] split(String patt,String str,Int limit=0,Bool allowempty=false) - Split a string into substrings.