Skip to Content
0
Former Member
Oct 02, 2009 at 10:31 PM

REGEX - find zip code in text

251 Views

Hi experts!

I have to find the zip code (for germany) in a given text. I found 5 digits in my text, but my problem is to ignore numbers which consists of more than 5 digits!

My first try works for all cases but not for the last one.

FIND FIRST OCCURRENCE OF REGEX '([0-9]{5})' IN ld_string SUBMATCHES ld_plz.

D-12345 Mainz -> should match 12345

D 12345 Mainz -> should match 12345

12345 Mainz -> should match 12345

12345Mainz -> should match 12345

Mainz D-12345 -> should match 12345

D-123 45 Mainz -> error because of the space between the numbers

D-12333345 Mainz -> error because only 5 digits are valid for a germany zip code; my REGEX does not work!

Thanks a lot!

Regards,

Florian