Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/node_modules/@stdlib/regexp/regexp/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* // returns false
*/
function reRegExp() {
return /^\/((?:\\\/|[^\/])+)\/([imgy]*)$/; // eslint-disable-line no-useless-escape
return /^\/((?:\\\/|[^\/])+)\/([dgimsuvy]*)$/; // eslint-disable-line no-useless-escape
}


Expand Down
8 changes: 4 additions & 4 deletions lib/node_modules/@stdlib/regexp/regexp/lib/regexp.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var reRegExp = require( './main.js' );
/**
* Matches parts of a regular expression string.
*
* Regular expression: `/^\/((?:\\\/|[^\/])+)\/([imgy]*)$/`
* Regular expression: `/^\/((?:\\\/|[^\/])+)\/([dgimsuvy]*)$/`
*
* - `/^\/`
* - match a string that begins with a `/`
Expand All @@ -51,15 +51,15 @@ var reRegExp = require( './main.js' );
* - `\/`
* - match the literal `/`
*
* - `([imgy]*)`
* - capture any characters matching `imgy` occurring zero or more times
* - `([dgimsuvy]*)`
* - capture any characters matching `dgimsuvy` occurring zero or more times
*
* - `$/`
* - string end
*
* @constant
* @type {RegExp}
* @default /^\/((?:\\\/|[^\/])+)\/([imgy]*)$/
* @default /^\/((?:\\\/|[^\/])+)\/([dgimsuvy]*)$/
*/
var RE_REGEXP = reRegExp();

Expand Down
22 changes: 22 additions & 0 deletions lib/node_modules/@stdlib/regexp/regexp/test/test.main.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,28 @@ tape( 'the function returns a regular expression that detects a regular expressi
t.end();
});

tape( 'the function returns a regular expression that detects a regular expression string having any supported flag', function test( t ) {
var values;
var RE;
var i;

RE = reRegExp();

values = [
'/beep/d',
'/beep/s',
'/beep/u',
'/beep/v',
'/beep/gimsuy',
'/beep/dgimsy'
];

for ( i = 0; i < values.length; i++ ) {
t.strictEqual( RE.test( values[i] ), true, values[i] );
}
t.end();
});

tape( 'the function returns a regular expression that detects a non-regular expression string', function test( t ) {
var values;
var RE;
Expand Down
19 changes: 19 additions & 0 deletions lib/node_modules/@stdlib/regexp/regexp/test/test.regexp.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,25 @@ tape( 'the regular expression detects a regular expression string', function tes
t.end();
});

tape( 'the regular expression detects a regular expression string having any supported flag', function test( t ) {
var values;
var i;

values = [
'/beep/d',
'/beep/s',
'/beep/u',
'/beep/v',
'/beep/gimsuy',
'/beep/dgimsy'
];

for ( i = 0; i < values.length; i++ ) {
t.strictEqual( RE.test( values[i] ), true, values[i] );
}
t.end();
});

tape( 'the regular expression detects a non-regular expression string', function test( t ) {
var values;
var i;
Expand Down
22 changes: 22 additions & 0 deletions lib/node_modules/@stdlib/utils/regexp-from-string/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,33 @@

for ( i = 0; i < values.length; i++ ) {
actual = reFromString( values[ i ] );
t.strictEqual( actual.toString(), expected[ i ].toString(), values[ i ] );

Check warning on line 91 in lib/node_modules/@stdlib/utils/regexp-from-string/test/test.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

This line has a length of 82. Maximum allowed is 80
}
t.end();
});

tape( 'the function returns a regular expression having any flag supported by the environment', function test( t ) {
var expected;
var actual;
var flags;
var i;

flags = [ 'd', 'g', 'i', 'm', 's', 'u', 'v', 'y' ];
for ( i = 0; i < flags.length; i++ ) {
expected = null;
try {
expected = new RegExp( 'beep', flags[ i ] );
} catch ( err ) { // eslint-disable-line no-unused-vars
// The environment does not support the flag...
}
if ( expected ) {
actual = reFromString( '/beep/' + flags[ i ] );
t.strictEqual( actual.toString(), expected.toString(), flags[ i ] );
}
}
t.end();
});

tape( 'the function returns `null` if unable to parse an input string as a regular expression', function test( t ) {
var values;
var i;
Expand Down
Loading