Re: How best to extract digits from a string?
Re: How best to extract digits from a string?
- Subject: Re: How best to extract digits from a string?
- From: Harald E Brandt <email@hidden>
- Date: Thu, 26 Apr 2001 23:10:00 +0200
+--> Bill Cheeseman wrote 01-04-25:
>
So now I filter for numerical digits as in this example:
>
>
set digits to "1234567890"
>
set input to "(800) 555-1212"
>
set output to "" -- initialize
>
repeat with char in every character of input
>
if char is in digits then set output to output & char
>
end repeat
>
get output --> "8005551212"
>
>
Is there a more efficient way to do this?
+--
This avoids the slow loop, is really fast,
but requires the osax RegEx Commands:
REReplace "++(800) 555-1212 - Mr. Jones" pattern "[^0-9]" with ""
--> "8005551212"
(The character after the first square bracket should be a 'hat')
______heb________________________________________________________________
Harald E Brandt email@hidden PGP/MIME aware
http://heb.surf.to