Allowed HTML 4.01 id values regex

后端 未结 1 1941
醉话见心
醉话见心 2021-02-20 07:54

Can you help me to build a regex that matches a valid W3C HTML 4.01 id value?

According with W3C specs:

ID and NAME tokens must begin

相关标签:
1条回答
  • 2021-02-20 08:23

    You can use this regex

    ^[a-zA-Z][\w:.-]*$
    

    ^ depicts the start of string

    [a-zA-Z] matches an uppercase or lowercase letter

    * matches the preceding character 1 to many times

    \w is similar to [a-zA-Z\d_]

    $ is the end of string

    0 讨论(0)
提交回复
热议问题