Hi Doug
I do not have to refer you as ddrudik since I looked at your profile and found your real name. Sorry for refering to you as ddrudik earlier!!!
I have few related questions to this regex. I am trying to understand the basics of this regex string so that I can create some variations myself without bugging you all the time. The string you gave is as follows.
(?=.*["| ]|(?:<!|expression\(|<[^>]*>|&#|script:| on[a-z]+=))
Can you please explain me the basics of the string above? Specifically my questions are as below
Q1) (?=.*["| ]|(?:<!|expression\(|<[^>]*>|&#|script:| on[a-z]+=)) - The bolded sequence ["| ] restricts the character " (quote) or | (pipe) or space from the string right? That means if I have to create a regex which needs to restrict only " (quote) and | (pipe) then I can change the regex to (?=.*["|]|(?:<!|expression\(|<[^>]*>|&#|script:|on[a-z]+=)) and it will work right?
Q2) If I do not need to restrict any of these characters (" (quote) or | (pipe) or space) , can I change the regex to (?=.*[]|(?:<!|expression\(|<[^>]*>|&#|script:|on[a-z]+=)) or there is a better way?
Q3) (?=.*["| ]|(?:<!|expression\(|<[^>]*>|&#|script:| on[a-z]+=)) - The bolded sequence is restricting the special sequences like <> etc right. Looking at the .net help, (?: matches pattern without capturing it. Just for my understanding, can we include the restrictions mentioned in Q1 as part of this sequence (?: and make it simple. Why we have 2 separate sections in the regex to restrict the characters in Q1 and character sequences like <> etc.
Q4) I have an existing regex for email addresses as follows. ^(?=.*@.*\.)(?!.*@.*@)(?!.*[/|\\;,<>\s]).+$. I need to modify this regex to restrict all the special sequences being referred in Q3 above. (<!, &#, script:, expression(, " on... ="). Please help me with this.
I know these are lot of questions. I do not have words to appreciate your help in this. The reason for questions Q1 - Q3 is so that I can learn this a little better and I can make some variations on my own.
Regards and thanks in advance
-Arun