Skip to content
Closed
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
20 changes: 20 additions & 0 deletions lib/node_modules/@stdlib/regexp/whitespace/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,26 @@ var out = replace( str, reWhitespace.REGEXP_CAPTURE, '$1$1' );

- Matches one related white space character without the Unicode character property "WSpace=Y" (zero width non-breaking space which was deprecated as of Unicode 3.2).

- Unlike the \s shorthand in JavaScript, @stdlib/regexp/whitespace explicitly targets Unicode 9.0 white space characters, ensuring consistency and compatibility across environments.
The predefined \s shorthand relies on the ECMAScript specification and may vary slightly in behavior, especially in older or less compliant environments.
Example demostrating difference
```javascript
var testString = 'Hello\u200BWorld';

var regex = /\s/;
console.log(regex.test(testString)); // returns true in some engines(ES5 or older)

var reWhitespace = require( '@stdlib/regexp/whitespace' );
var RE_WHITESPACE = reWhitespace();
console.log(RE_WHITESPACE.test(testString)); // returns false

var arr = testString.split(regex);
console.log(arr); // ["Hello", "World"]

arr = testString.split(RE_WHITESPACE);
console.log(arr); // ["Hello\u200BWorld"]
```

- The `REGEXP` regular expression is defined as

```text
Expand Down
Loading