# RegexpMapper

Implements \FileNameMapper

Uses regular expressions to perform filename transformations.

author | Andreas Aderhold andi@binarycloud.com
author | Hans Lellelid hans@velum.net
package | phing.mappers

### Methods

## Instantiage regexp matcher here.

    __construct()

## The mapper implementation.

    main(mixed $sourceFileName) : array|null

### Arguments

#### $sourceFileName

`mixed`

The data the mapper works on.

### Response

`array|null`

## Replace all backreferences in the to pattern with the matched groups.

    replaceReferences(string $source) : array|null|string

groups of the source.

intern | the expression has already been processed (when ->matches() was run in Main()) so no need to pass $source again to the engine. Replaces \1 with value of reg->getGroup(1) and return the modified "to" string.

### Arguments

#### $source

`string`

The source filename.

### Response

`array|null|string`

FIXME Can't we just use engine->replace() to handle this? the Preg engine will automatically convert \1 references to $1

## Gets the matched group from the Regexp engine.

    replaceReferencesCallback(array $matches) : string

### Arguments

#### $matches

`array`

Matched elements.

### Response

`string`

## Sets the &quot;from&quot; pattern. Required.

    setFrom(string $from) : void

### Arguments

#### $from

`string`

On what this mapper should work

## Sets the &quot;to&quot; pattern. Required.

    setTo(string $to) : void

intern | [HL] I'm changing the way this works for now to just use string `$this->to = StringHelper::toCharArray($to);`

### Arguments

#### $to

`string`

To what this mapper should convert the from string

### Properties

## to

    to : string

var |

### Type(s)

`string`

## The Regexp engine.

    reg : \Regexp

var |

### Type(s)

`\Regexp`