patternInOutCapture
patternInOutCapture(
pattern,options?):string
Defined in: packages/core/src/pattern/pattern-util.ts:55
Enclose the pattern with in-out capture groups, provided pre/post pattern
strings.
inCaptureName is the name of the inner capture group (the main pattern).
outCaptureName is the name of the outer capture group (the whole pattern
with pre/post).
If inCaptureName is not provided, the inner capture group will be
non-capturing. If outCaptureName is not provided, the outer capture group
will be non-capturing.
The prePattern and postPattern are added before and after the main
pattern, respectively.
Exemple:
const pattern = patternInOutCapture("\\d+", { prePattern: "\\(", postPattern: "\\)", inCaptureName: "number", outCaptureName: "parenthesizedNumber",});// pattern is "(?<(parenthesizedNumber)>(?:\\((?<number>\\d+)\\)))"// new RegExp(pattern) is /(?(<parenthesizedNumber>)(?:\((?<number>\d+)\)))/Parameters
Section titled “Parameters”pattern
Section titled “pattern”string
The main pattern to be captured.
options?
Section titled “options?”PatternInOutCaptureOptions = {}
Options for pre/post patterns and capture group names.
Returns
Section titled “Returns”string
The composed pattern string with in-out capture groups.