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.