I have some difficulties to run regex for these cases - sorry, I'm very new to regex and can't figure it out.
The sample looks like this:
- 12 (true)
- 123 (true)
- 1234 (true)
- 12345 (true)
- 1 a ... (false)
- 12 a ... (false)
- 123 a ... (false)
- 1234 a ... (false)
- 12345 m (true)
- 12345 mün (true)
- münchen 123 (false)
- mün 12345 (true)
therefore, if combined with the letters, the zip code must fill in the maximum length specified in the range eg {2,5} .
I tried with this, but it does not work as I need it:
/^([0-9]{2,5})(\s+[^a-zA-Z]{2,})?$/
source share