The id attribute values in HTML 5 has the following rules
1.The string should contain nonwhitespace characters
2. It should contain at least one letter
How can i represent this in regular expression form.I reached in a regular expression which satisfies the first condition..
/(^|\s)\S+/ig
But how can i indicate the second condition in to the above regular expression
…and I am new to regular expressions…
You have got your restrictions wrong. The HTML5 ID data type must:
That’s:
Done.
Note:
\Sis not a character), you don’t have to make your regex case-insensitive (/.../iis superfluous).^...$) there can only ever be a single match. This means there is no need for the “global” modifier, so/.../gis superfluous as well.