test2(){
let text: string =
"Please contact us at support@geeksforgeeks.org or at courses@geeksforgeeks.org";
let emailRegex = /\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}\b/g;
let emails = text.matchAll(emailRegex);
for (const match of emails) {
console.log("Found email address:", match[0]);
}
}
test3(){
let descriptions: string[] = [
"Product 123 (ABC-DEF) is the best!",
"Buy Product ID 456 now!",
"This is not a product description.",
];
const idRegex = /\bProduct\s+(\d+)\b|\bID\s+(\w+)\b/g;
for (const description of descriptions) {
const matches = description.matchAll(idRegex);
for (const match of matches) {
console.log("Product ID:", match[1] || match[2]);
}
}
}