I am using nodejs
v8.9.4 and typescript
v2.6.2. I want to build a Regexp
that can turn on and off case sensitivity like it do the (?i)
and (?-i)
modifier spans for example in the .NET
environment.
I want to accomplish something like:
let value = 'HelloWorld';
let pattern = '(?i)\\b(' + value + ')\\:|' +
'(?-i)\\b(' + value.toUpperCase() + '|' + value + ')\\b';
let myRegex = new RegExp(pattern, 'g');
myRegex.test('helloworld'); // returns false
myRegex.test('helloworld:'); // returns true
myRegex.test('HELLOWORLD'); // returns true
myRegex.test('HelloWorld'); // returns true
Unfortunately javaScript does not support modifier spans.
So I am asking is there a way to build a Rexep
in javaScript like the myRegex
of the example above where the value
is assignable/exchangeable.
Every hint is welcome, thank's in advance.