I need to match strings that do not contain the keyword ( beta2) in an arbitrary position.
Consider:
var aStr = [
'/beta1/foo',
'beta1/foo',
'/beta1_xyz/foo',
'blahBlah/beta1/foo',
'beta1',
'/beta2/foo',
'beta2/foo',
'/beta2_xyz/foo',
'blahBlah/beta2/foo',
'beta2',
'/beat2/foo',
'beat2/foo',
'/beat2_xyz/foo',
'blahBlah/beat2/foo',
'beat2'
];
function bTestForMatch (Str)
{
return /.*\b(?!beta2).*/i.test (Str);
}
for (var J=0, iLen=aStr.length; J < iLen; J++)
{
console.log (J, bTestForMatch (aStr[J]), aStr[J]);
}
We need a regular expression that matches all lines that exclude beta2. beta2always begins with the word boundary, but does not necessarily end with one. It can be in various positions in a row.
Desired Results:
0 true /beta1/foo
1 true beta1/foo
2 true /beta1_xyz/foo
3 true blahBlah/beta1/foo
4 true beta1
5 false /beta2/foo
6 false beta2/foo
7 false /beta2_xyz/foo
8 false blahBlah/beta2/foo
9 false beta2
10 true /beat2/foo
11 true beat2/foo
12 true /beat2_xyz/foo
13 true blahBlah/beat2/foo
14 true beat2
A regular expression is used for a third-party analysis tool that accepts JavaScript regular expressions to filter subsamples. The tool takes one line of regular expression. The API is missing and we do not have access to its source code.
JavaScript-, - (beta2) ?