RegExpCreator module
It has three API methods:
create()
The create(string, true) method with the second parameter set to true instead of RegExp, returns an object containing three properties:
-
lookbehind- is actuality a capturing group; is non-empty group only with accuracy options:'exactly'or{ 'value' : 'exactly', 'limiters': .. }, and'startsWith'or{ 'value' : 'startsWith', 'limiters': .. }.
It can be easily converted to lookbehind assertion by replacing the first(by(?<=. -
pattern- a string pattern -
lookahead- is real lookahead assertion pattern; is non-empty string only with accuracy option:'exactly'or{ 'value' : 'exactly', 'limiters': .. }.
These properties can be used in options object: accuracy, diacritics, synonyms, caseSensitive, ignoreJoiners, ignorePunctuation, and wildcards.
See mark() method for properties details.
import RegExpCreator from './regexpcreator.es6.js';
const creator = new RegExpCreator(options);
const obj = creator.create(string, true);
console.log(obj.lookbehind, obj.pattern, obj.lookahead);
createCombinePattern()
The createCombinePattern(array, capture) method creates combine pattern from an array of string; returns an object containing three properties:
-
lookbehind- is the same as increate()method; -
pattern- a combine pattern itself. If thecaptureparameter set to true, an individual pattern is wrapped in a capturing group, false - non-capturing group. -
lookahead- is the same as increate()method;
// the 'creator' and the accepted options are the same as in above example
const obj = creator.createCombinePattern(array, true);
console.log(obj.pattern); // true - (ptn1)|(ptn2)|(ptn3); false - (?:ptn1)|(?:ptn2)|(?:ptn3)
createDiacritics()
The createDiacritics(string) method returns a string diacritic pattern.
It's affected only by one option : caseSensitive.
import creator from './regexpcreator.es6.js';
const pattern = new creator(options).createDiacritics(string);
console.log(pattern);