Skip to content

Instantly share code, notes, and snippets.

@iamjono
Created July 7, 2014 16:08
Show Gist options
  • Save iamjono/6a4afc8da406a154d0bc to your computer and use it in GitHub Desktop.
Save iamjono/6a4afc8da406a154d0bc to your computer and use it in GitHub Desktop.
2 examples of how to extract numeric strings such as phone numbers
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