Download code

Jump to: navigation, search

Back to Soundex_(Sed)

Download for Windows: single file, zip

Download for UNIX: single file, zip, tar.gz, tar.bz2

soundex.sed

 1 y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/
 2 s/[^A-Z]//g
 3 h
 4 #/* (1) Convert characters to numerics using table:                    */
 5 #/*     0 = A,E,H,I,O,U,W,Y                                            */
 6 #/*     1 = B,F,P,V                                                    */
 7 #/*     2 = C,G,J,K,Q,S,X,Z                                            */
 8 #/*     3 = D,T                                                        */
 9 #/*     4 = L                                                          */
10 #/*     5 = M,N                                                        */
11 #/*     6 = R                                                          */
12 
13 y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/01230120022455012623010202/
14 
15 #/* (2) Make multiple digits single.                                   */
16 
17 :setify
18 s/\(.\)\1/\1/
19 tsetify
20 
21 #/* (3) Remove zeroes after first position.                            */
22 
23 :denull
24 s/\(.\)0/\1/
25 tdenull
26 #/* (4) Fill on right with zeroes to make 6 characters.                */
27 
28 s/$/000000/
29 s/\(......\).*/\1/
30 #/* (5) Replace first digit with first character of name.              */
31 G
32 s/.\(.....\).*\n\(.\).*/\2\1/


hijacker
hijacker
hijacker
hijacker