I am scratching my head around for this small yet confusing requirement that I have.
I need a regular expression for the name field which only allows letters, apostrophes, full stops, mas and hyphens. Name field also should not allow more than 150 characters.
Any help would be much appreciated!
I am scratching my head around for this small yet confusing requirement that I have.
I need a regular expression for the name field which only allows letters, apostrophes, full stops, mas and hyphens. Name field also should not allow more than 150 characters.
Any help would be much appreciated!
Share Improve this question edited May 22, 2018 at 16:35 Ωmega 43.7k35 gold badges142 silver badges211 bronze badges asked Nov 6, 2012 at 16:03 user869375user869375 2,4196 gold badges29 silver badges47 bronze badges 3- This apparently matches part of the string....^[- a-zA-Z'\.,][^/]{1,150}. But if I have numbers at the end of string like test1, it does not work. – user869375 Commented Nov 6, 2012 at 16:10
- Is allowing numbers a requirement? You didn't specify that in the question. What language are you using? Can you give some example data showing what should match and what should not match? – Bill the Lizard Commented Nov 6, 2012 at 16:12
-
Is
ä
a letter according to your definition? – Tim Pietzcker Commented Nov 6, 2012 at 16:25
1 Answer
Reset to default 12Use regex pattern
^[a-zA-Z'.,-]{0,150}$
If minimum length is also required, replace 0
with such number...