Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (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 by ddx

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...