英文:
regex pattern to not start with numbers but has to be alphanumeric with dash
问题
pattern="^(?!0-9+)[a-zA-Z0-9\d-]+$"
pattern="^[a-zA-Z][A-Za-z0-9_]*\S+$"
英文:
I'm looking for a html regex pattern to not accept numbers in the start of a string and no spaces but can allow alphanumeric with dash . Example " February-2023 " but not "2023February"
I tried the following patterns:
pattern="^(?!0-9+)[a-zA-Z0-9\d\-]+$"
pattern="^[a-zA-Z][A-Za-z0-9_]*\S+$"
答案1
得分: 0
^[a-zA-Z]([a-zA-Z0-9]*-[a-zA-Z0-9]*)+$
英文:
If you need hyphen/dash is mandatory, try this one: ^[a-zA-Z]([a-zA-Z0-9]*-[a-zA-Z0-9]*)+$
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论