const regex = /[\x{0080}-\x{02AF}\x{0300}-\x{03FF}\x{0600}-\x{06FF}\x{0C00}-\x{0C7F}\x{1DC0}-\x{1DFF}\x{1E00}-\x{1EFF}\x{2000}-\x{209F}\x{20D0}-\x{214F}\x{2190}-\x{23FF}\x{2460}-\x{25FF}\x{2600}-\x{27EF}\x{2900}-\x{29FF}\x{2B00}-\x{2BFF}\x{2C60}-\x{2C7F}\x{2E00}-\x{2E7F}\x{3000}-\x{303F}\x{A490}-\x{A4CF}\x{E000}-\x{F8FF}\x{FE00}-\x{FE0F}\x{FE30}-\x{FE4F}]/g;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('[\\x{0080}-\\x{02AF}\\x{0300}-\\x{03FF}\\x{0600}-\\x{06FF}\\x{0C00}-\\x{0C7F}\\x{1DC0}-\\x{1DFF}\\x{1E00}-\\x{1EFF}\\x{2000}-\\x{209F}\\x{20D0}-\\x{214F}\\x{2190}-\\x{23FF}\\x{2460}-\\x{25FF}\\x{2600}-\\x{27EF}\\x{2900}-\\x{29FF}\\x{2B00}-\\x{2BFF}\\x{2C60}-\\x{2C7F}\\x{2E00}-\\x{2E7F}\\x{3000}-\\x{303F}\\x{A490}-\\x{A4CF}\\x{E000}-\\x{F8FF}\\x{FE00}-\\x{FE0F}\\x{FE30}-\\x{FE4F}]', 'g')
const str = `Тест ⚡`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
while ((m = regex.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions