A factory class for regex functions.

author Hans Lellelid
package phing.util.regexp
version $Id$

 Methods

Constructor sets the regex engine to use (preg by default).

__construct($engineType) 

Parameters

$engineType

Get specific matched group.

getGroup(integer $idx) : string

Parameters

$idx

integer

Returns

stringspecified group or NULL if group is not set.

Get array of matched groups.

getGroups() : array

Returns

arrayMatched groups

Gets whether the regexp matching is case insensitive.

getIgnoreCase() : boolean

Returns

boolean

Gets pattern modifiers.

getModifiers() : string

Subsequent call to engines getModifiers() filters out duplicates i.e. if i is provided in $mods, and setIgnoreCase(true), "i" modifier would be included only once

Returns

string

Gets whether regexp is to be applied in multiline mode.

getMultiline() : boolean

Returns

boolean

Gets pattern to use for matching.

getPattern() : string

Returns

stringThe pattern to match on.

Gets replacement string.

getReplace() : string

Returns

stringThe pattern to replace matches with.

Performs match of specified pattern against $subject.

matches(string $subject) : boolean

Parameters

$subject

string

The subject, on which to perform matches.

Returns

booleanWhether or not pattern matches subject string passed.

Performs replacement of specified pattern and replacement strings.

replace(string $subject) : string

Parameters

$subject

string

Text on which to perform replacement.

Returns

stringsubject after replacement has been performed.

Sets whether the regexp matching is case insensitive.

setIgnoreCase(boolean $bit) 

(default is false -- i.e. case sensisitive)

Parameters

$bit

boolean

Sets pattern modifiers for regex engine

setModifiers(string $mods) : void

Parameters

$mods

string

Modifiers to be applied to a given regex

Sets whether regexp should be applied in multiline mode.

setMultiline(boolean $bit) 

Parameters

$bit

boolean

Sets pattern to use for matching.

setPattern(string $pat) : void

Parameters

$pat

string

The pattern to match on.

Sets replacement string.

setReplace(string $rep) : void

Parameters

$rep

string

The pattern to replace matches with.

 Properties

 

$engine : \RegexpEngine

'preg' or 'ereg';

 

$groups : array
 

$pattern : string
 

$replace : string