Consider the following input: BEGINsomeotherstuffEND
I'm trying to write a regular expression to replace BEGIN and END but only if they both exist.
I got as far as:
(^BEGIN|END$)
Using the following c# code to then perform my string replacement:
private const string Pattern = "(^guid'|'$)";
private static readonly Regex myRegex = new Regex(Pattern, RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.ExplicitCapture | RegexOptions.Singleline | RegexOptions.IgnoreCase);
var newValue = myRegex.Replace(input, string.empty);
But unfortunately that matches either of those - not only when they both exist.
I also tried:
^BEGIN.+END$
But that captures the entire string and so the whole string will be replaced.
That's about as far as my Regular Expression knowledge goes.
Help!