const regex = /^([^\p{Han}]*?)(?:\s+([\p{Han}].*))?$/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('^([^\\p{Han}]*?)(?:\\s+([\\p{Han}].*))?$', 'gm')
const str = `Companyaaaaaaaa. 有限公司有限公司有限公司
Companybbbbbb (asdasd) xxx 有限公司有限公司有限公司
Companyccccccccccc (cccc) Co., Ltd. 有限公司有限公司(集团)有限公司
CompanyD aaa ccc. Ltd.
CompanyE Capital ccccc Co., Ltd.
GroupF Capital asddddc Limited 有限公司有限公司有限公司(有限公司)
HoldingG Group (dasdddddq) Limited 有限公司有限公司
HoldingH asddc axcaCasd 有限公司/ 有限公司
GroupI Capital 有限公司集团
CaptialI Capital 有限公司
`;
// 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