-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sun, 18 Apr 2004 21:17:18 +0300 (IDT), Geoffrey S. Mendelson <[EMAIL PROTECTED]> 
wrote:
>
> Enclosed is a perl script I wrote (in simple easy to follow code) that
> reads a file exported by morotola phone tools, and converts it. The
> actual conversion is done in a subroutine that can be used elsewhere.

Below is an Emacs command that will find current cellular phone numbers
and possibly (with user approval) will replace it.

The following formats are searched: 972[56]nnnnnnn, 0[56]nnnnnnn,
972[56]n-nnnnnn, 0[56]n-nnnnnn (see the SRCH regular expression).
The replacing number preserve the found format.

Ehud.



(defun cell-number-change ()
  "Operate repeatedly on Israeli 6 digits cellular phone numbers in the buffer.
Change it to the new number (7 digits) after user confirmation.

The changes are:
    Pelephone: 050- ==> 050-5, 051- ==> 050-7, 056- ==> 050-6, 068- ==> 050-8,
    Cellcom:   052- ==> 052-2, 053- ==> 052-3, 058- ==> 052-8, 064- ==> 052-4, 065- 
==> 052-5,
    Orange:    054- ==> 054-4, 055- ==> 054-5, 066- ==> 054-6, 067- ==> 054-7,
    Mirs:      057- ==> 057-7
Other numbers (059) are not changed."
       (interactive)
       (let ((RPLC "050722234445067728XXXXXXXXXX2425464708XX")
                   ;; new phone number prefix (digit after 05) + 1st digit of the new 
number OR XXX (no change)
             (SRCH 
"[^0-9]\\(972\\|0\\)\\([56][0-9]\\)\\([-]?\\)\\([0-9][0-9][0-9][0-9][0-9][0-9]\\)[^0-9]")
                   ;; a number starting with 972 or 0, followed by 5 or 6 , any digit, 
possible hyphen (Makaf)
                   ;; and ending by any 6 digits (but no more).
             beg end P+D ix
             (NUM "x")                                     ;; any non nil value
             (uop 0))
           (while (and NUM (re-search-forward SRCH nil 1)) ;; search such formated 
number
               (setq beg (1+ (match-beginning 0)))         ;; start of OLD number
               (setq end (1- (match-end 0)))               ;; end of OLD number
               (setq NUM (buffer-substring beg end))
               (setq ix (ash (- (string-to-number
                           (buffer-substring (match-beginning 2) (match-end 2)))   ;; 
Zone part (5/6+digit)
                               50) 1))                                 ;; Index 50=0, 
69=19  * 2
               (setq P+D (substring RPLC ix (+ ix 2)))                 ;; last digit 
of zone part + 1st digit
               (or (string-equal P+D "XX")                             ;; Nothing to 
replace
                   (= uop ?a)                                          ;; Replace all 
is ON
                   (progn
                       (message  "Old Number is \"%s\", type S(kip), Q(uit), A(ll) or 
other to replace: " NUM)
                       (setq uop (downcase (read-char-exclusive)))))
               (cond
                   ((= uop ?q)                                         ;; Quit NOW
                       (setq NUM nil))
                   ((or (= uop ?s)                                     ;; skip OR
                        (string-equal P+D "XX"))      )                ;; Nothing to 
replace
                   (t
                       (or (= (match-beginning 3) (match-end 3))       ;; = is no "-" 
(Makaf)
                           (setq P+D (concat
                                       (substring P+D 0 1)             ;; last zone 
digit
                                       "-"                             ;; Makaf
                                       (substring P+D 1 2))))          ;; 1st new 
number digit
                       (setq NUM (concat
                               (buffer-substring (match-beginning 1) (match-end 1))    
;; 972 or 0
                               "5" P+D                                                 
;; Zone + 1st new digit
                               (buffer-substring (match-beginning 4) (match-end 4))))  
;; original 6 digits
                       (delete-region beg end)
                       (goto-char beg)
                       (insert NUM))))))



- --
 Ehud Karni           Tel: +972-3-7966-561  /"\
 Mivtach - Simon      Fax: +972-3-7966-667  \ /  ASCII Ribbon Campaign
 Insurance agencies   (USA) voice mail and   X   Against   HTML   Mail
 http://www.mvs.co.il  FAX:  1-815-5509341  / \
 GnuPG: 98EA398D <http://www.keyserver.net/>    Better Safe Than Sorry
-----BEGIN PGP SIGNATURE-----
Comment: use http://www.keyserver.net/ to get my key (and others)

iD8DBQFAhCg7LFvTvpjqOY0RAiDhAKCLQji3tTTt3C+SYPIkEjHb2u+bvwCfW0fj
lMNfYOKD0Dk4lgNZT9+GT3w=
=YU2x
-----END PGP SIGNATURE-----

=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to