I\'m having some difficulty with a specific Regex I\'m trying to use. I\'m searching for every occurrence of a string (for my purposes, I\'ll say it\'s \"mystring\") i
Regular expression searches are typically not a good idea in XML. It's too easy to run into problems with search expressions matching to much or too little. It's also almost impossible to formulate a regex that can correctly identify and handle CDATA sections, processing instructions (PIs), and escape sequences that XML allows.
Unless you have complete control over the XML content you're getting and can guarantee it won't include such constructs (and won't change) I would advise to use an XML parser of some kind (XDocument or XmlDocument in .net, for instance).
Having said that, if you're still intent on using regex as your search mechanism, something like the following should work using the RegEx class in .NET. You may want to test it out with some of your own test cases at a site like Regexlib. You may also be able to search their regular expression catalog to find something that might fit your needs.
[>].(_mystring_).[<]
_mystring_(?![^<]*?>)
But a valid HTML structure is required.