const regex = new RegExp('(?P<bar>\\+[+\\-=]+\\+)(?P<headline>.*?)(\\+[+\\-=]+\\+)(?P<body>.*?)(\\+[+\\-=]+\\+)', 'gms')
const str = `+----+--------------------------------------+-------------+----------+--------+--------+--------------------+------------------+-------+-----------------+------------------------------+------------+-----------+--------------+------------+---------------------------------------------+---------------------+---------+
| No | ID | Name | VNFM | VIM | Tenant | VNF Package | Flavor | Level | Aspect | VNF Status | Job Status | Scale Opt | Scale Mode | Scale Unit | Workflow | Created At | Visible |
+----+--------------------------------------+-------------+----------+--------+--------+--------------------+------------------+-------+-----------------+------------------------------+------------+-----------+--------------+------------+---------------------------------------------+---------------------+---------+
| 0 | 0960ad53-bf7a-4c56-b980-cfa05a33fe71 | vzw_u13_cp3 | NSA_VNFM | simvim | vran | vzw_u13_cp3_i12i00 | VRAN-FLAVOR | 0 | SA_CPC=0 | vnf.instance.instantiate.end | COMPLETED | Enabled | Auto Scale | VDU | workflow_etsi-com-vnf_nfvo_direct_1_0_0.jar | 2021-01-12 04:35:51 | true |
| 1 | 33434187-2d82-48bd-9fd0-c67f2a8c9c87 | vzw_usm14 | NSA_VNFM | simvim | vsm | vzw21a_usm14 | VEMS-FLAVOR-TINY | 0 | AS_CF=0,AS_PS=0 | vnf.instance.instantiate.end | COMPLETED | Disabled | Manual Scale | VDU | workflow_etsi-com-vnf_nfvo_direct_1_0_0.jar | 2020-12-24 14:22:03 | true |
| 2 | 94b68ddb-06e6-45ae-a7dc-bf9204f61aa3 | vzw_usm12 | NSA_VNFM | simvim | vsm | vzw21a_usm12 | VEMS-FLAVOR-TINY | 0 | AS_CF=0,AS_PS=0 | vnf.instance.instantiate.end | COMPLETED | Disabled | Manual Scale | VDU | workflow_etsi-com-vnf_nfvo_direct_1_0_0.jar | 2020-12-24 13:15:55 | true |
| 3 | b60fdfff-c8d7-4656-bd77-d4621c1efbe5 | vzw_usm13 | NSA_VNFM | simvim | vsm | vzw21a_usm13 | VEMS-FLAVOR-TINY | 0 | AS_CF=0,AS_PS=0 | vnf.instance.instantiate.end | COMPLETED | Disabled | Manual Scale | VDU | workflow_etsi-com-vnf_nfvo_direct_1_0_0.jar | 2020-12-24 13:51:24 | true |
| 4 | c3de1762-57fb-4c0f-875e-e3b960629663 | vzw_u13_up3 | NSA_VNFM | simvim | vran | vzw_u13_up3_i12i00 | VRAN-FLAVOR | 0 | SA_UPC=0 | vnf.instance.instantiate.end | COMPLETED | Enabled | Auto Scale | VDU | workflow_etsi-com-vnf_nfvo_direct_1_0_0.jar | 2021-01-12 04:26:30 | true |
+----+--------------------------------------+-------------+----------+--------+--------+--------------------+------------------+-------+-----------------+------------------------------+------------+-----------+--------------+------------+---------------------------------------------+---------------------+---------+
item count : 5
[vnf-list] OK`;
// 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