RegExp \P Metacharacter
Examples
let text = "Hello 😄";
let pattern = /\p{RGI_Emoji}/v;
let result = pattern.test(text);
Try it Yourself »
let text = "Hello 😄";
let pattern = /\p{RGI_Emoji}/;
let result = pattern.test(text);
Try it Yourself »
Description
The \p{Unicode Property} metacharacter matches any character with a Unicode character property.
Syntax
new RegExp("\\P{Unicode Property}","v")
or simply:
/\P{Unicode Property}/v
Note
\p and \P are only supported in Unicode-aware mode.
This means that the \u flag or the \v flag must be set.
Regular Expression Methods
Regular Expression Search and Replace can be done with different methods.
These are the most common:
String Methods
Method | Description |
---|---|
match(regexp) | Returns an Array of results |
matchAll(regexp) | Returns an Iterator of results |
replace(regexp, s) | Returns a new String |
replaceAll(regexp, s) | Returns a new String |
search(regexp) | Returns the index of the first match |
split(regexp) | Returns an Array of results |
regexp Methods
Method | Description |
---|---|
regexp.exec() | Returns an Iterator of results |
regexp.test() | Returns true or false |
Browser Support
/\P{}/
is a JavaScript 2018 feature.
ES 2018 is supported in all modern browsers since June 2020:
Chrome 63 | Edge 79 | Firefox 78 | Safari 12 | Opera 50 |
Des 2017 | Jan 2020 | Jun 2020 | Sep 2018 | Jan 2018 |