How to match euro € sign in javascript regexp with octal, hexadecimal or unicodal metacharacter?

I need to create hexadecimal and octal metacharacters in regexp. I found on the Internet a link that the octal code for € 200and hexadecimal 80, but when I try to match € with a regular expression \200and \x80it does not match the € sign. Only the unicode metacharacter \u20ACworks fine. Do I have the wrong codes or is it impossible to match the euro to the oct and hex metacharacters? I had no such problems with other characters before.

var a = "200€"

console.log(a.search(/\200/g));     //-1
console.log(a.search(/\x80/g));     //-1
console.log(a.search(/\u20AC/g));   //3
Run codeHide result
+4
source share
4

, £, £ 00A3 A3, javascript regexp as \u00A3 { } \xA3 { }. A3 , , 243, , \243 { } £. , unicode 20AC, , \u20AC { }, { }, 00. 20AC 20254, , { }.

, , , \xdd regexp metacharacter, , , \ddd. , € U+20AC, ❤ U+2764, ☯ U+262F, ❄ U+2744, \udddd javascript.

+1

- U + 20AC, U + 0080. 8- , 0x80 Euro, Windows-1252, Unicode. euro 8- escape- JavaScript.

0

Try this clean javascript hack (lalz):

var txt = 'This will cost 3€';
console.log(encodeURI(txt).indexOf('%E2%82%AC'));
-1
source

It seems like it could be some kind of mistake.

console.log("Euro symbol: \x80");
console.log("Pound symbol: \xA3");
Run codeHide result
-1
source

Source: https://habr.com/ru/post/1671195/


All Articles