[REBOL] Re: Fast way to remove all non-numerical chars from a string
From: pwawood:g:mail at: 23-Sep-2007 9:59
Tom
That's a good example of using parse to modify it's input string:
thanks. (I was struggling to come up with this approach myself).
I modified the rule to search for strings of digits rather than
individual ones (some digit instead of digit); there was a 30 per cent
reduction in the time taken. If Kai's data has a very high percentage
of digits, this small improvement may be significant.
The revised code is:
digit: charset "0123456789"
noise: complement digit
start: now/time/precise
rule: [some digit | here: some noise there:(remove/part :here :there)
:here]
loop 1'000'000 [parse/all "(250) 764-0929"[some rule]]
now/time/precise - start
Peter
On Sunday, September 23, 2007, at 08:22 am, Tom wrote: