I want to check some C # source code for a scripting engine. I want to make sure that only members of the System.Math class can refer to it. I am trying to create a regular expression that will match a point, followed by a capital letter, followed by any number of word characters ending in a word boundary that is NOT preceded by System.Math.
I started with this:
(?<!Math)\.[AZ]+[\w]*
Which is great for:
return Math.Max(466.89/83.449 * 5.5);
It matches .Max correctly when it is not preceded by mathematics. However, now when I try to extend the regex to include System, I cannot get it to work.
I tried these regex permutations and more:
((?<!System\.Math)\.[AZ]+[\w]*) ((?<!(?<!System)\.Math)\.[AZ]+[\w]*) ((?<!System)\.(?<!Math)\.[AZ]+[\w]*) ((?<!System)|(?<!Math)\.[AZ]+[\w]*) ((?<!System\.Math)|(?<!Math)\.[AZ]+[\w]*)
Using these statements:
return System.Math.Max(466.89/83.449 * 5.5); return System.Xath.Max(466.89/83.449 * 5.5); return Xystem.Math.Max(466.89/83.449 * 5.5);
I tried everything I could think of, but it either ALWAYS matches the second element (.Math or .Xath above), or doesn't match anyone.
If someone had mercy on me and indicated what I was doing wrong, I would be very carried away.
Thanks in advance, Welton
Welton v3.57
source share