How to get or extract zipcode from any position and format regex?

It will get as long as valid zipcode , it will extract or check if zipcode exists in some examples below. Thank you.

Example input :


Example input :
output: 19460

example input :
output: 123451234

example input:
12345 1234
output : 12345 1234

current regex: ^\d{5}([-]|\s*)?(\d{4})?$

Thank you guys.

give a try on:
(\d| |-){5,}

1 Like

please psot the answer sir hehe

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.