im trying to extract the shop title and address before an address regex match. I've been stuck for a while. Thanks! Eventually I want to get the telephone as well but im not sure how. Can someone help me with this?
Function:
function getShopInfo(text) {
const addrRegex = /[0-9]+.+(Singapore\s+\d{6}|S\d{6})/g;
const titleRegex = `/(.*\n){1}${addrRegex}/`; // extract the title before the address
if (text.match(titleRegex)) {
const title = text.match(titleRegex);
console.log(title);
console.log(addr);
console.log("\n")
} else {
console.log('Message: No TITLE before ADDRESS found!');
}
}
Text:
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
Final Output:
Paragon
290 Orchard Road #B1-03 Singapore 238859
BreadTalk IHQ
30 Tai Seng Street #01-02 Singapore 534013
City Square Mall
180 Kitchener Road #01-10 Singapore 208539
Chinatown Point
133 New Bridge Road #02-01 Singapore 059413