Due to an unfortunate past choice I have a following format string that looks like this:
# {0}mm {1}mm x {2}mm
It's processed in two stages, first one was to replace #
character with a string with simple
formatString = formatString.Replace("#", "foo")
Somehow the original string changed to include octothorpes inside the format string as:
# {0}mm {1:0.##}mm x {2:0.##}mm
Because I still have to replace the first one #
with foo
, but the string.Replace("#","foo")
will replace all occurences of #
, resulting in foo {0}mm {1:0foofoo}mm x {2:0.foofoo}mm"
That's why I'd like to replace #
symbol only if it's not inside curly braces. I think it can be achieved by a regex, but the correct expression doesn't come to my mind.