const regex = /'([\p{L}]+)/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('\'([\\p{L}]+)', 'gm')
const str = `'가락시장(340)',
'가락시장(8)',
'가산디지털단지(7)',
'강남(222)',
'강남구청',
'강동',
'강동구청',
'강변(214)',
'개롱',
'개화산',
'거여',
'건대입구(212)',
'건대입구(7)',
'경복궁(317)',
'경찰병원(341)',
'고덕',
'고려대',
'고속터미널(329)',
'고속터미널(7)',
'공덕(5)',
'공덕(6)',
'공릉',
'광나루',`;
// 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