RegExp

RegExp is a class to handle regular expressions.

It is the core foundation for adding powerful string pattern matching capabilities to programs like grep, text editors, awk, sed, etc.

Constructors

this
this(string pattern, string attributes)

Construct a RegExp object. Compile pattern with <i>attributes</i> into an internal form for fast execution.

Members

Enums

REA
enum REA
Undocumented in source.

Functions

compile
void compile(string pattern, string attributes)
Undocumented in source. Be warned that the author may not have intended to support it.
exec
string[] exec(string s)

Search string[] for match.

exec
string[] exec()

Pick up where last exec(string) or exec() left off, searching string[] for next match.

find
sizediff_t find(string string)

Search string[] for match with regular expression.

match
string match(size_t n)

Same as opIndex(n).

match
string[] match(string s)

Search s[] for match.

opApply
int opApply(int delegate(ref RegExp) dg)

Set up for start of foreach loop.

opIndex
string opIndex(size_t n)

Retrieve match n.

replace
string replace(string s, string format)

Find regular expression matches in s[]. Replace those matches with a new string composed of format[] merged with the result of the matches. If global, replace all matches. Otherwise, replace first match.

replace
string replace(string format)

After a match is found with test(), this function will take the match results and, using the format string, generate and return a new string.

replaceOld
string replaceOld(string format)

* Like replace(char[] format), but uses old style formatting: <table border=1 cellspacing=0 cellpadding=5> <th>Format <th>Description <tr> <td><b>&</b> <td>replace with the match </tr> <tr> <td><b>\</b><i>n</i> <td>replace with the <i>n</i>th parenthesized match, <i>n</i> is 1..9 </tr> <tr> <td><b>\</b><i>c</i> <td>replace with char <i>c</i>. </tr> </table>

search
RegExp search(string string)

Set up for start of foreach loop.

split
string[] split(string s)

Split s[] into an array of strings, using the regular expression as the separator.

test
bool test(string s)

* Search s[] for match. * Returns: 0 for no match, !=0 for match * Example:

test
int test()

Pick up where last test(string) or test() left off, and search again.

test
int test(string s, size_t startindex)

Test s[] starting at startindex against regular expression.

Properties

post
string post [@property getter]

Return the slice of the input that follows the matched substring.

pre
string pre [@property getter]

Return the slice of the input that precedes the matched substring.

Static functions

opCall
RegExp opCall(string pattern, string attributes)

Generate instance of RegExp.

replace3
string replace3(string format, string input, regmatch_t[] pmatch)
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

attributes
uint attributes;
Undocumented in source.
errors
int errors;
Undocumented in source.
flags
string flags;
Undocumented in source.
input
string input;
Undocumented in source.
pattern
string pattern;
Undocumented in source.
pmatch
regmatch_t[] pmatch;
Undocumented in source.
re_nsub
uint re_nsub;
Undocumented in source.

Meta