/[0-9]+[a-z]?(?:$|\b)/i I guess a regular expression should be suitable. The above is from my head and untested. [0-9]+ – matches any amount of numbers [a-z]? – optionally matches a letter (?:$|\b) – either matches the end of the string or a word boundary (space, dot, etc.) /i – search case insensitve
Should work for the examples you gave. You might want to limit the [a-z] to [a-l] because I haven't even heard of an "123 f", so it ignores some of the typos (i.e. 3r avenue). No idea how that works for languages other than English. The regex will find "5" as housenumber if someone e.g. writes "5. avenue". On Fri, Mar 13, 2009 at 16:28, Marcus Wolschon <mar...@wolschon.biz> wrote: > Hello, > > does anyone know a good algorithm to extract > the house-number from a string containing > street-name and house-number? > Cases coollected so far: > > // "xyz 12" > // "xyz 12b" > // "11b xyz" > // "11 xyz" > // "xyz" > // "5th avenue" > // "3rd avenue" > // "2nd avenue" > // "1st avenue" > > I need it for adding routing to house-numbers to the Traveling > Salesman -navigator. > > > Marcus > > _______________________________________________ > dev mailing list > dev@openstreetmap.org > http://lists.openstreetmap.org/listinfo/dev > -- Please encrypt your mail: http://mathphys.fsk.uni-heidelberg.de/~stefan/publickey.asc FP: 2620 E737 FD50 60AB 86B6 1B9D 3BFD AFFB 5B15 6893 _______________________________________________ dev mailing list dev@openstreetmap.org http://lists.openstreetmap.org/listinfo/dev