Some Keywords(Blue)
Expression used: \W(?<match>Me|Class|Structure|End)\W
Me, Class, Structure and End are just four of the keywords, in the real expression all keywords are included. The \W is since I only want to find the exact match of the words. Not a match in Meters for example.
Comments(Green)
Expression used: '.*
A VB.NET comment starts with a single quote and continues to the end of the line whatsoever.
Strings(Red)
Expression used: ".*"
A VB.NET string is enclosed in double quotes
The problems I'm having:
Two things in this isn't working though and I hope someone could help me fix the regular expressions so it will work properly. The two things is:
1) Since my first regular expression is searching for one non word character on each side of the keyword it won't find both Class and End in the following example:
End Class
The reason is because there's only one Non-Word character between the keyword, they want one each. And if I only search for a non-word character before/after the keyword(instead of both) it won't solve the actual problem(only before: meters will match Me. Only after: vend will match End).
2)Regular expression #2 and #3 works fine on their own but together a problem will occur. Consider this line:
MessageBox.Show("This is a single quote ' and will cause a problem", myCaption, MessageBoxButtons.OK)
The regular expression #2 and #3 will get a match each and it will result in this highlighting:
MessageBox.Show([COLOR="red"]"This is a single quote ' and will cause a problem"[/COLOR][COLOR="green"],myCaption, MessageBoxButtons.OK)[/COLOR]
The reason is that regular expression #3 finds the string and paints it red(as it should), regular expression #2 finds the single quote and paints everything after it green(as it usually should, but now it shouldn't since it's not a comment when it's a part of the string). Since expression #3 is painting after #2 the red will cover the green inside the string and the result will be that all text after the string will still be green.
Any ideas on how to solve these two problems. Thanks in advance.
/Vswe :)


Sign In
Create Account


Back to top









