validation - building a simple regex for @Pattern -


i need validate string should represent house number. unfortunately in country (probably others well) these house numbers can consists of numbers , letters. because of cant use integer, make lot easier validate. i've been looking around explanations , find lots of them i'm having serious difficulties grasping subject. since need (simple?) pattern once, hope can me out here.

so need regex pattern validates if inserted string has number (but maximum of 4) of positive numbers followed maximum 1 letter. correct expression this?

all need this:

^\d{1,4}[a-za-z]?$

explanation:

^\d{1,4} anchor ^ beginning of string, followed 1-4 digits

[a-za-z]?$ letter, 0 or 1 times, @ end of string ($)


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -