Используйте только один шаблон: захватите заголовок в первой группе захвата (все на его строке), а на следующей строке, захватите ди git в начале строки, за которым следует Singapore
, с
(.+)\n(\d+.*Singapore \d{6}\b)
https://regex101.com/r/VEKqjw/1
const input = `LOCATE US
Din Tai Fung (Singapore, Thailand and United Kingdom) is managed by Taster Food Pte Ltd.
Din Tai Fung Singapore: We regret to inform that online/email reservations are not accepted. Please
Name
Contact
Email
Subject
Restaurant
Message
SINGAPORE RESTAURANTS TEL
Paragon
290 Orchard Road #B1-03 Singapore 238859+65 6836 8336
BreadTalk IHQ
30 Tai Seng Street #01-02 Singapore 534013
+65 6702 0060
City Square Mall
180 Kitchener Road #01-10 Singapore 208539
+ 65 6634 2322
Chinatown Point
133 New Bridge Road #02-01 Singapore 059413
+65 6534 2722`;
for (const [, title, address] of input.matchAll(/(.+)\n(\d+.*Singapore \d{6}\b)/g)) {
console.log(title)
console.log(address);
}
Или без matchAll
:
const input = `LOCATE US
Din Tai Fung (Singapore, Thailand and United Kingdom) is managed by Taster Food Pte Ltd.
Din Tai Fung Singapore: We regret to inform that online/email reservations are not accepted. Please
Name
Contact
Email
Subject
Restaurant
Message
SINGAPORE RESTAURANTS TEL
Paragon
290 Orchard Road #B1-03 Singapore 238859+65 6836 8336
BreadTalk IHQ
30 Tai Seng Street #01-02 Singapore 534013
+65 6702 0060
City Square Mall
180 Kitchener Road #01-10 Singapore 208539
+ 65 6634 2322
Chinatown Point
133 New Bridge Road #02-01 Singapore 059413
+65 6534 2722`;
const pattern = /(.+)\n(\d+.*Singapore \d{6}\b)/g;
let match;
while (match = pattern.exec(input)) {
const [, title, address] = match;
console.log(title)
console.log(address);
}