const regex = /(?<=Country of origin Index.*\n)(?:(?!ROBERTO)(?!Country of origin)[\s\S\n])*/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(?<=Country of origin Index.*\\n)(?:(?!ROBERTO)(?!Country of origin)[\\s\\S\\n])*', 'gm')
const str = `ROBERTO S.R.L.
Automotive Aftermarket
ROBERTO S.R.L., Str. Horia Macelariu nr. 30-34, RO-013937 Bucuresti
Capitalul Social: 169.363.000 Lei, Nr. Ord. Reg. com.: J40/7601/1994
Citibank Europe Plc Dublin, Romania Branch Citibank Europe Plc Dublin, Bulgaria Branch
SWIFT CODE: CITIROBU SWIFT CODE: CITIBGSF
IBAN RON: RO45 CITI 0000 0007 2488 3001 IBAN BGN: BG54 CITI 9250 1001 0086 00
IBAN EURO: RO48 CITI 0000 0007 2488 3044
Invoice 1/ 2
Document No.: 2045158199
Date: 20.05.2022
Sold To party: 95100938
Account No.: 95100938
ALFREDO GIOACCHINO OOD
ul. Andrey Germanov 11
BG-1336 SOFIA
Your VAT No.: BG175423111
Our VAT No.: RO5541546
Contact Person Finance: VALENTINA IVANOVA
Phone: +35929601062
E-mail: Valentina.Ivanova@bg.bosch.com
Contacts: IVA GYONEVA
Phone: +359029601056
E-mail: external.Iva.Gyoneva@bg.bosch.com
Sold To Address: ALFREDO GIOACCHINO OOD, ul. Andrey Germanov 11, BG-1336 SOFIA, B
Item Material/Description Quantity Unit Price per unit Net Value BGN
Transport: 1180736236 Shipping Point: ADC/LDC DE, Karlsruhe Shipping Type: Truck
Ship To Party: 95100938 ALFREDO GIOACCHINO OOD
ul. Andrey Germanov 11
BG-1336 SOFIA
Delivery No.: 822656882 Delivery Date: 27.05.2022 Delivery Type: Standard Order AA
Your Order No.: 20220420-132109-436R From: 20.04.2022 Our Order No.: 15402739
10 Nozzle And Holder Assy 6 EA
Material: 0.432.191.301.741
Material Entered: 0.432.191.301
EAN: 3165143436226
82,32 493,92
Dispatch element: 105755352 6 EA
Your Order No.: 20220509-135611-091G From: 09.05.2022 Our Order No.: 210012705
20 Nozzle And Holder Assy 6 EA
Material: 0.432.191.301.741
Material Entered: 0.432.191.301
EAN: 3165143436226
82,32 493,92
Dispatch element: 105755352 6 EA
Your Order No.: 20220513-121235-468D From: 13.05.2022 Our Order No.: 210024679
30 mechanical steering pump 2 EA
Material: K.S00.000.394.002
Material Entered: K.S00.000.394
EAN: 4047025443456
565,00 1.130,00
Dispatch element: 105755352 2 EA
Total net value: 2.117,84
VAT:* Z9 0,00 % 2.117,84 0,00
Invoice amount: 2.117,84
* Triangular transaction taxable at the customer according to Art. 141, 2006/112/EC
Incoterms: DAP SOFIAROBERTO S.R.L.
Automotive Aftermarket
ROBERTO S.R.L., Str. Horia Macelariu nr. 30-34, RO-013937 Bucuresti
Capitalul Social: 169.363.000 Lei, Nr. Ord. Reg. com.: J40/7601/1994
Citibank Europe Plc Dublin, Romania Branch Citibank Europe Plc Dublin, Bulgaria Branch
SWIFT CODE: CITIROBU SWIFT CODE: CITIBGSF
IBAN RON: RO45 CITI 0000 0007 2488 3001 IBAN BGN: BG54 CITI 9250 1001 0086 00
IBAN EURO: RO48 CITI 0000 0007 2488 3044
Invoice 2/ 2
Document No.: 2045158199
Date: 20.05.2022
Sold To party: 95100938
Account No.: 95100938
Payment terms: Up to 03.06.2022 you receive 2,000 % discount
Up to 19.06.2022 without deduction
Country of origin Index (represents the last three digits of part number)
Brazil 741
Germany 002
Country of origin HS Code Quantity UoM Amount BGN
Brazil
84099900 12 EA 987,84
987,84
Germany
84136061 2 EA 1.130,00
1.130,00
Marking Dispatch element type Physical dimension of dispatch
element
Unit of
measure
Gross
Weight Unit of measure
105755352 Corrug. brown box RB-logo 550X35 550 350 300 MM 14,880 KG
Country of origin Item numbers Total amount
Brazil 10 20 987,84
Germany 30 1.130,00
Element type: Corrug. brown box RB-logo 550X35Number of elements: 1 14,880 KG`;
// 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