ddx Posted December 9, 2003 Posted December 9, 2003 (edited) Background: I'm 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? Edited December 10, 2003 by ddx Quote
ddx Posted December 10, 2003 Author Posted December 10, 2003 Oops... small typo above. i meant to write oMatch.Length not Match.Length. I corrected the original post. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.