Created
July 9, 2023 03:39
-
-
Save tajulasri/010eb726de2dfd2728a3cdd493d67ac8 to your computer and use it in GitHub Desktop.
Regex router for Mail delivery Zone
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@hannyramzy snippet ni boleh test kat https://www.programiz.com/javascript/online-compiler/ untuk verify regex rules dia.