I want to use regex to find a text between two words. This almost works. But it also returns parts of the words that are searched for.
Result: sub)a(/sub But I need: a Only the letter a. Possibly (sub) and (/sub) can occur several times in the string.
How do I have to change the regex expression? Thanks.
var start = "(sub)";
var end = "(/sub)";
var text = "Border Low P(sub)a(/sub) 12";
var text2 = "Border Low P(sub)a(/sub) and (sub)b(/sub)";
Regex regex = new Regex($"{start}(.+?){end}");
var v = regex.Match(text);
// result: sub)a(/sub