最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Regular Expression - letters, apostrophes, full stops, commas and hyphens are allowed - Stack Overflow

programmeradmin3浏览0评论

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
Add a ment  | 

1 Answer 1

Reset to default 12

Use regex pattern

^[a-zA-Z'.,-]{0,150}$

If minimum length is also required, replace 0 with such number...

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论