const regex = /([\S]+\s*)\|/g;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('([\\S]+\\s*)(?:\\|)', 'g')
const str = ` src-mobile/C/sms-order/build.config.js | 3 +-
src-mobile/C/sms-order/index.vue | 4 +-
src-mobile/invoiceForm/App.vue | 7 +-
src-mobile/invoiceForm/build.config.js | 3 +-
src-mobile/invoiceForm/page/index.vue | 7 +-
src-pc/distributor-order/build.config.js | 3 +-
.../page/distributors-records/index.vue | 15 +-
.../page/invoice-distributors/index.js | 64 +-
.../page/invoice-distributors/index.xtpl | 42 +-
src-pc/e-invoice/normal/build.config.js | 4 +-
.../e-invoice/normal/components/invoice-config.vue | 409 +++++++++++
.../normal/components/product-select/index.js | 253 +++++++
.../normal/components/product-select/index.scss | 273 +++++++
.../normal/components/product-select/index.xtpl | 80 +++
.../normal/components/product-ticket-select.vue | 312 ++++++++
src-pc/e-invoice/normal/page/getAddress/index.vue | 87 ++-
src-pc/e-invoice/normal/page/goods-name/index.vue | 1 -
.../e-invoice/normal/page/invoice-drawer/index.js | 1 -
.../e-invoice/normal/page/invoice-records/index.js | 15 +-
.../e-invoice/normal/page/merchant-manage/index.js | 1 -
src-pc/e-invoice/normal/page/products/index.js | 790 +++++++++------------
src-pc/e-invoice/normal/page/products/index.scss | 96 ++-
src-pc/e-invoice/normal/page/products/index.xtpl | 271 ++++---
src-pc/e-invoice/normal/router/index.js | 14 +-
src-pc/e-invoice/normal/service/index.js | 13 +-
25 files changed, 2034 insertions(+), 734 deletions(-)`;
let m;
while ((m = regex.exec(str)) !== null) {
// 这对于避免零宽度匹配的无限循环是必要的
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
// 结果可以通过`m变量`访问。
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
console