Some examples of metacharacters and special symbols in JS regular

Source: Internet
Author: User

1. metacharacters in regular Expressions:

The code is as follows

([{\^ $ |)? * +.

Example 1:

Alert (/\?/.test ("?"));

Example 2:

Alert (/\\?/.test ("?"));

Double escape, avoid translation by translation n mode?

2. Special characters

1. Use ASCII to represent a character

Specifies a two-bit hexadecimal code preceded by x, such as: X62 is a B-B character with an ASCII code of 98, equal to 16 62

Example 1:

The code is as follows

var scolor= "Blue";
var reb=/\x62/;
Alert (Reb.test (Scolor));

1428 in to B

Example 2:

The code is as follows

var scolor= "Blue";
var reb=/\142/;
Alert (Reb.test (Scolor));

2.Unicode with u plus four hexadecimal notation B is 0062

Example 3:

The code is as follows

var scolor= "Blue";
var reb=/\u0062/;
Aert (Reb.test (Scolor));

3. Other special characters

R
special character  
description
T tab
n return
page feed
a alert character
e escape character
">" "> CX corresponding control characters for x
b fallback character
v vertical tab
  null character

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.