Background: Im using Regex.Match and string expressions for string matching.
For instance, if:
String sMatchString = @"SOFT>?(WARE)";
and sString = "SOFTWARE",
then I get oMatch.Length > 0 from:
Match oMatch = Regex.Match(sString, sMatchString);
And oMatch.Length < 0 if sString is anything else such as "SOFTWXRE"
My problem: I want to invert the evaluation of sMatchString . I want oMatch.Length to be > 0 if sString contains at its end anything *except* "WARE". I thought i could simply insert the ! operator like so:
String sMatchString = @"SOFT>?(!WARE)";
so that if sString = "SOFTWXRE" then oMatch.Length would be > 0.
But this does not work.
What is most frustrating is that following prefix approach does work:
String sMatchString = @"(?<!SOFT)WARE";
Suggestions?
For instance, if:
String sMatchString = @"SOFT>?(WARE)";
and sString = "SOFTWARE",
then I get oMatch.Length > 0 from:
Match oMatch = Regex.Match(sString, sMatchString);
And oMatch.Length < 0 if sString is anything else such as "SOFTWXRE"
My problem: I want to invert the evaluation of sMatchString . I want oMatch.Length to be > 0 if sString contains at its end anything *except* "WARE". I thought i could simply insert the ! operator like so:
String sMatchString = @"SOFT>?(!WARE)";
so that if sString = "SOFTWXRE" then oMatch.Length would be > 0.
But this does not work.
What is most frustrating is that following prefix approach does work:
String sMatchString = @"(?<!SOFT)WARE";
Suggestions?
Last edited by a moderator: