![]() |
The RegExp u modifier in JavaScript, which came into existence at ECMAScript 2015 (ES6), makes it possible to have full support for Unicode in regular expressions. This means that emoji or other characters outside of the 16-bit range as well as symbols and scripts beyond the Basic Multilingual Plane (BMP) can be processed correctly by regex operations, the reason why regex matching becomes more accurate and comprehensive for international text is because the u modifier ensures that patterns are interpreted as Unicode code points rather than UCS-2 code units. Syntax/regexp/u or new RegExp("regexp", "u") Example 1: The given below example matches a character outside the BMP with u modifier.
Output Match found: ???? Example 2: The given below example demonstrates how to use the u flag correctly.
Output Without 'u' modifier: null With 'u' modifier: ???? Supported BrowsersThe RegExp
|
Reffered: https://www.geeksforgeeks.org
JavaScript |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 12 |