JavaScript RegExp \S meta character
- Previous Page \s
- Next Page \b
- Go to the Previous Level JavaScript RegExp Reference Manual
Definition and usage
\S
Meta characters match non-whitespace characters.
Whitespace characters can be:
- Space character
- Tab
- Carriage return
- New line
- Vertical tab
- Page break
Example
Global search for non-whitespace characters:
let text = "Is this all there is?"; let pattern = /\S/g;
Syntax
new RegExp("\\S")
Or abbreviated as:
/\S/
Syntax with modifiers
new RegExp("\\S", "g")
Or abbreviated as:
/\S/g
Browser support
/\S/
It is an ECMAScript1 (ES1) feature.
All browsers fully support ES1 (JavaScript 1997):
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Supported | Supported | Supported | Supported | Supported | Supported |
Regular expression search methods
In JavaScript, regular expression text search can be completed using different methods.
UsagePattern (pattern)As regular expressions, these are the most commonly used methods:
Example | Description |
---|---|
text.match(pattern) | String method match() |
text.search(pattern) | String method search() |
pattern.exec(text) | RexExp method exec() |
pattern.test(text) | RexExp Method test() |
- Previous Page \s
- Next Page \b
- Go to the Previous Level JavaScript RegExp Reference Manual