Forum Discussion
Mike_Finney_119
Nimbostratus
Sep 06, 2013iRule regex to normalize phone numbers?
Been searching but no luck so far looking for a iRule with a regex or some other method to normalize phone numbers from AD for use to pass to an SMS gateway.
I have adapted the method here: https://...
JRahm
Admin
Sep 06, 2013Or instead of string map, you can strip non-numeric characters:
%proc justNumbers {pn} {
set nums "0 1 2 3 4 5 6 7 8 9"
set newNumber ""
foreach x [split $pn ""] {
if { !([lsearch $nums $x] == -1) } {
append newNumber $x
}
}
return $newNumber
}
% set x1 "1-800-632-6223"
1-800-632-6223
% set x2 "1.800.632.6223"
1.800.632.6223
% set x3 "1(800)632-6223"
1(800)632-6223
% justNumbers $x1
18006326223
% justNumbers $x2
18006326223
% justNumbers $x3
18006326223
assuming of course you have 11.4 (procs support), you can use this function or a similar one with string map (might be a little faster) and call it as necessary from same or different iRules.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects