abstract class RegexpConvertor

create a method that replaces capturing subpatterns with non-capturing subpatterns, and perhaps even no subpattern at all. Unless backreferences are used

Properties

static protected $unicodePropsRegexp

Regexp that matches Unicode properties escape sequences

static protected $unicodeProps

Ranges to be used in JavaScript regexps in place of PCRE's Unicode properties

Methods

static string
toJS(string $regexp, bool $isGlobal = false)

Convert a PCRE regexp to a JavaScript regexp

static string
convertUnicodeCharacters(string $str, bool $inCharacterClass, bool $dotAll)

Replace Unicode characters and properties in a string

static string
escapeLineTerminators(string $regexp)

Escape line terminators in given regexp

static string
serializeOption(array $tok)

No description

static string
serializeCapturingSubpatternStart(array $tok)

No description

static string
serializeNonCapturingSubpatternStart(array $tok)

No description

static string
serializeCapturingSubpatternEnd(array $tok)

No description

static string
serializeNonCapturingSubpatternEnd(array $tok)

No description

static string
serializeCharacterClass(array $tok)

No description

static string
serializeLookaheadAssertionStart(array $tok)

No description

static string
serializeNegativeLookaheadAssertionStart(array $tok)

No description

static string
serializeLookaheadAssertionEnd(array $tok)

No description

static string
serializeNegativeLookaheadAssertionEnd(array $tok)

No description

static string
unfoldUnicodeProperties(string $str, bool $inCharacterClass, bool $dotAll)

Replace Unicode properties in a string

Details

at line 30
static string toJS(string $regexp, bool $isGlobal = false)

Convert a PCRE regexp to a JavaScript regexp

Parameters

string $regexp

PCRE regexp

bool $isGlobal

Whether the global flag should be set

Return Value

string

JavaScript regexp

at line 87
static protected string convertUnicodeCharacters(string $str, bool $inCharacterClass, bool $dotAll)

Replace Unicode characters and properties in a string

NOTE: does not support \X

Parameters

string $str

Original string

bool $inCharacterClass

Whether this string is in a character class

bool $dotAll

Whether PCRE_DOTALL is set

Return Value

string

Modified string

at line 104
static protected string escapeLineTerminators(string $regexp)

Escape line terminators in given regexp

Parameters

string $regexp

Original regexp

Return Value

string

Modified regexp

at line 129
static protected string serializeOption(array $tok)

No description

Parameters

array $tok

Return Value

string

at line 139
static protected string serializeCapturingSubpatternStart(array $tok)

No description

Parameters

array $tok

Return Value

string

at line 144
static protected string serializeNonCapturingSubpatternStart(array $tok)

No description

Parameters

array $tok

Return Value

string

at line 154
static protected string serializeCapturingSubpatternEnd(array $tok)

No description

Parameters

array $tok

Return Value

string

at line 159
static protected string serializeNonCapturingSubpatternEnd(array $tok)

No description

Parameters

array $tok

Return Value

string

at line 164
static protected string serializeCharacterClass(array $tok)

No description

Parameters

array $tok

Return Value

string

at line 169
static protected string serializeLookaheadAssertionStart(array $tok)

No description

Parameters

array $tok

Return Value

string

at line 174
static protected string serializeNegativeLookaheadAssertionStart(array $tok)

No description

Parameters

array $tok

Return Value

string

at line 179
static protected string serializeLookaheadAssertionEnd(array $tok)

No description

Parameters

array $tok

Return Value

string

at line 184
static protected string serializeNegativeLookaheadAssertionEnd(array $tok)

No description

Parameters

array $tok

Return Value

string

at line 201
static protected string unfoldUnicodeProperties(string $str, bool $inCharacterClass, bool $dotAll)

Replace Unicode properties in a string

NOTE: does not support \X

Parameters

string $str

Original string

bool $inCharacterClass

Whether this string is in a character class

bool $dotAll

Whether PCRE_DOTALL is set

Return Value

string

Modified string