Created
July 7, 2014 16:08
-
-
Save iamjono/6a4afc8da406a154d0bc to your computer and use it in GitHub Desktop.
2 examples of how to extract numeric strings such as phone numbers
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
define numeric_string(in::string) => { | |
local(out = string) | |
with char in #in->split('') where string_isNumeric(#char) and #char != '-' && #char != '+' do => { #out->append(#char) } | |
return #out | |
} | |
define numeric_string2(in::string) => { | |
return string_replaceregexp(#in, -find='\\D', -replace='') | |
} | |
numeric_string('123_456-7890') | |
numeric_string2('(123) 456-7890') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment