Sunday, 1 September 2013

Postcode and Country Match with Javascript

Postcode and Country Match with Javascript

i have some difficulties to get a regex running for this cases - sorry i´m
very new to regex and can´t figure it out.
the pattern look like this
12 (true)
123 (true)
1234 (true)
12345 (true)
123 münchen (false)
12345 münchen (true)
12345 mün (true)
münchen 123 (false)
mün 12345 (true)

so if combined with letters, postcode has to fullfill the max lenth given
in the range like {2,5}
I tried with this one, but is doesn´t work like i need it

/^([0-9]{2,5})(\s+[^a-zA-Z]{2,})?$/
can somebody help me out thx in advanced

No comments:

Post a Comment