In my application,id attribute of HTML elements should begin with #..
According to HTML5 ,the only restriction in id attribute is that ,it should not contain any whitespaces and should be atleast one character long..
So i wrote the following regular expression which matches an id attribute according to the above said constraints
idMatch: /^#\S+$/
Now i want to remove the # character in the beginning of string…
My question is , can i do both the operations in one regular expression…ie..
can i extract the characters after first ‘#'(characters may contain any nonwhitespace character including ‘#’) in a string matching the above said constraints using a single regular expression.The result of match should do two things
1)Identify id string from a set of strings (ids begin with # and follows HTML5 id naming rules)
2)Extract the part of the recognized string after first #..
You can use parentheses in RegExes to do what you want.