JS Regular control character \cx

Source: Internet
Author: User
Tags control characters

Text: JS Regular control character \cx

Some days ago in Masaki's group, someone asked this question: what exactly is a special character \cx in a regular expression?
Yes, I did, but I didn't see what was going on.
Only control characters on MDN (see Using special characters for details), but what are control characters?
In the "JavaScript Standard reference Tutorial (Alpha)" in Ruan Feng, the explanation is:\cx represents ctrl-x
But what exactly will ctrl-x produce? I do not know, although the Wikipedia found an explanation, but did not understand, can only write the demo test.
After reading this test, I believe you will understand the second.

var str = '; For storing \X00-\XFF this 256 character for (var i=0; i<=255; i++) {    str + string.fromcharcode (i);//Fill character}var c= ",//character after transcoding 
   re,   //store dynamically generated expression    m;    Store matching results for (var i=65; i<=90; i++) {//ASCII 65-90 correspond to characters a-Z    = String.fromCharCode (i);//Convert to character A-Z    re = R Egexp (' \\c ' +c); Generate regular Expression \ca-\cz    m = Str.match (re);//Match    if (m) {//if matched to the output        console.log (i, Re, Escape (M[0]));//Output as CII code, regular, matched to the character    }}

You can click "Run" in the top right corner to see the results.
Believe that smart you can see what \cx really is at the first glance.

Well, today's share is over, see you tomorrow.

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.