Reputation: 4097
How to validate the below Housenumber using jquery Form validation?
1
1b
12
12b
123
123b
1234
1234b
the letter should be always last position , but not required. Please help me to create regular expression.
Upvotes: 4
Views: 5237
Reputation: 1792
regex "^\\d+/?\\d*[a-zA-Z]?(?<!/)$"
will match numbers like:
Upvotes: 2
Reputation: 7964
Please correct me if wrong. String can can not end with two more digits. In this case "\d+[a-zA-Z]?" should work
Upvotes: 1
Reputation: 349262
The following RegExp will do:
/^\d+[a-zA-Z]*$/
^
Must start with\d+
Any number (\d
), at least once (+
)[a-zA-Z]*
Some letters [a-zA-Z]
(optional: *
)$
Must end hereUpvotes: 9