Skip to content

Instantly share code, notes, and snippets.

@tajulasri
Created July 9, 2023 03:39
Show Gist options
  • Save tajulasri/010eb726de2dfd2728a3cdd493d67ac8 to your computer and use it in GitHub Desktop.
Save tajulasri/010eb726de2dfd2728a3cdd493d67ac8 to your computer and use it in GitHub Desktop.
Regex router for Mail delivery Zone
// Online Javascript Editor for free
// Write, Edit and Run your Javascript code using JS Online Compiler
const regexRules = [
{regexp: new RegExp('\\edu\\.my$'),sendingZone: 'testing-sending-zone'},
{regexp: new RegExp('\\gov\\.my$'),sendingZone: 'gov-sending-zone'}
];
const email = 'test@admin.gov.my';
if(regexRules.length > 0) {
for(let regex of regexRules) {
//console.log(regex.regexp);
console.log(regex.regexp.test(email))
if (regex.regexp.test(email)) {
//routing.sendingZone = pRegex.sendingZone;
console.log("rules match=> " + regex.sendingZone)
}
}
}
@tajulasri
Copy link
Author

@hannyramzy snippet ni boleh test kat https://www.programiz.com/javascript/online-compiler/ untuk verify regex rules dia.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment