On Thu, Apr 04, 2013 at 10:26:53AM +0200, Michael Strey wrote:

[...]

> Usually my phone links look like [[tel:+49 351 4129535]]; but since I
> imported data sets from a larger contact data base that had evolved over
> time, I ended up with stuff like this in my data base:
> 1. [[tel:0033 (0) 4568-33]]
> 2. [[tel:+49 (0)3 8899 66]]
> 3. [[tel:0351 41295-35]]
> 4. [[tel:0351/4129535]]
> 5. [[tel:(0351) 412 95-35]]
> 
> My filter function currently handles the cases 1. to 4. but (for no
> other reason than carelessness) not 5.

[...]

Here is a re-work of the filter function that handles all off the above
cases correctly.

#+BEGIN_SRC emacs-lisp
(defun trim-phone-number (phonenumber)
  "Remove whitespaces from a telephone number"
  (setq trimmed_phonenumber
     (mapconcat 'identity
        (split-string
        (mapconcat 'identity
                   (split-string phonenumber "(0)") "") "[()/ -]") "")))
#+END_SRC

I'm a Elisp newbie.  I'm sure that there are smarter solutions to solve this
problem.

Regards
-- 
Michael Strey 
www.strey.biz

Reply via email to