const regex = /[^第]([ -~φθ°α’−]+)(?![個])/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('[^第]([ -~φθ°α’−]+)(?![個])', 'gm')
const str = ` 第2の装置1gbは、実施の形態9においてその詳細を説明した装置1であって、1 + Y個のMOSトランジスタを備える。各MOSトランジスタの状態は、保護IC 88により制御される。
そして、9以上のMOSトランジスタを備えてもよいし、11以上のMOSトランジスタを備えてもよいし、N以上のMOSトランジスタを備えてもよい。
そして、8個のMOSトランジスタを備えてもよいし、12個のMOSトランジスタを備えてもよいし、N個のMOSトランジスタを備えてもよい。`;
// 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