ruby - regex for matching german postal codes but not a -
following string:
23434 5465434
58495 / 46949345
58495 - 46949345
58495 / 55643
d 44444 ssdfsdf
64784
45643 dfgh
58495/55643
48593/48309596
675643235
34565435 34545
it want extract bold ones. 5 digit number(german). should not match telephone numbers 43564 366334
or 45433 / 45663
,etc in example above.
i tried ^\b\d{5}
thats not beginning.
some hints me working?
thanks hints
you add negative look-ahead assertion avoid matches phone numbers.
\b[0124678][0-9]{4}\b(?!\s?[ \/-]\s?[0-9]+)
if you're using ruby 1.9, can add negative look-behind assertion well.
Comments
Post a Comment