Members
Symbol
Created by raoul-becke--s0-v1 on 08.12.16. A JavaScript Regular Expression library, extending the standard RegExp
class with missing functionality.
- Source:
- See:
Methods
getRegexCompleteGroupingStructure(regexopt) → {*}
Takes the regular expression "regex" as input and puts all the non-grouped regex characters before a group
opening "(") into additional groups: "(xyz)" so in the end all relevant parts of the regular expression
(relevant in the sense that they are required to calculate the starting position of each group) are grouped.
AND finally returns the group structure of this regex:
[[index, originalIndex, 'regexForThisGroup', [[child01Index, child01OriginalIndex, 'regexForThisChild01Group', [...]], [child02Index, child02OriginalIndex, ..., [...]], ...]]].
The array elements are:
- index: This is the group index in the regular expression
- originalIndex: This is the groups index in the initial/original regular expression. "originalIndex" is "undefined"
if this group was the result of the group completion.
- regexForThisGroup: The regular expression of this group including its parantheses
- child-array: An array containing the child regular expressions
SPECIAL: indexMap: The first element contains one more array element: [1]: indexMap: This array maps the
original-index [0..n] to the actual-index [0..m]
SPECIAL: source: The first element contains one more array element: [2]: source: This is the initial regular
expression pattern and the only reason this is required is because in RegExp.source the slash "/" needs to be
escaped.
Rule for group parsing: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp
And: http://www.ecma-international.org/ecma-262/6.0/#sec-regexp-regular-expression-objects
The capturing groups are numbered according to the order of left parentheses of capturing groups, starting from 1.
The matched substring can be recalled from the resulting array's elements [1], ..., [n] or from the predefined
RegExp object's properties $1, ..., $9.
The good thing is that the regular expression rules around groups (and as well in most other parts of the regular
expression) did not change between the different ECMA Script versions respective did not have any impact on the
group parsing and therefore this function is compatible between the different browsers!
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
regex |
String |
<optional> |
Returns:
- Type
- *
getRegexCompleteGroupingStructureInternal(regex, posIndexOrigIndex, isCapturingGroup, indexMap, source) → {*}
Description see getRegexCompleteGroupingStructure.
Parameters:
Name | Type | Description |
---|---|---|
regex |
||
posIndexOrigIndex |
this array has 3 values: [0]:position: while iterating through the regular expression the parsing position is incremented starting at 0 [1]:index: the index of the current group we are parsing [2]:original index: the original index the group had before we added additional groups | |
isCapturingGroup |
tells us whether this group of characters enclosed within parantheses is a capturing group or not. If not it could be a non capturing group (?:xyz) or an assertion which starts as well with a group bracket "(" character but is followed with a "?=" or "?!" and tells us that this is not a capturing group | |
indexMap |
this array maps the original-index [0..n] to the actual-index [0..m] | |
source |
This is the initial regular expression pattern and the only reason this is required is because in RegExp.source the slash "/" needs to be escaped. |
Returns:
- Type
- *