C# Regex replace with Regex -
i have problem, want replace every "[[:de:<text>]]" "{{de|<text>}}" in text. tried
output = regex.replace(input, "[[:de:(.*)]]", "{{de|(.*)}}");
but doesnt copy <text>. have no other idea how replace correctly. hope can me.
use lazy dot pattern , backreferences , escape [
symbols:
output = regex.replace(input, @"\[\[:de:(.*?)]]", "{{de|$1}}");
if text between de:
, ]]
can contain line breaks, use regexoptions.singleline
modifier.
see regex demo.
Comments
Post a Comment