I have a string like:
[a b=\"c\" d=\"e\"]Some multi line text[/a]
Now the part d=\"e\"
is optional. I want to convert such type of
For HTML tags, please use HTML parser.
For [a][/a], you can do like following
Match m=Regex.Match(@"[a b=""c"" d=""e""]Some multi line text[/a]",
@"\[a b=""([^""]+)"" d=""([^""]+)""\](.*?)\[/a\]",
RegexOptions.Multiline);
m.Groups[1].Value
"c"
m.Groups[2].Value
"e"
m.Groups[3].Value
"Some multi line text"
Here is Regex.Replace (I am not that prefer though)
string inputStr = @"[a b=""[[[[c]]]]"" d=""e[]""]Some multi line text[/a]";
string resultStr=Regex.Replace(inputStr,
@"\[a( b=""[^""]+"")( d=""[^""]+"")?\](.*?)\[/a\]",
@"$3",
RegexOptions.Multiline);