0

I'm practicing on python regex substitution with macros in property sheet. In a brute-force way, I'm doing something like:

config_regex = re.compile(r'$(Configuration)')
test_str = r'<Import Project="$(SolutionDir)\PropertySheets\Optimization.$(Configuration).props" />'
print config_regex.sub(r'Release', test_str)

However, the macro in my test string doesn't seem to be substituted. It still prints:

<Import Project="$(SolutionDir)\PropertySheets\Optimization.$(Configuration).props" />

Please help me out a little. Thanks.

ZDunker
  • 437
  • 1
  • 6
  • 18

1 Answers1

0

EDIT: (Tim's comment is right) If the regex starts with $ it will try to match at the beginning end of the string

Also, the parentheses have a special meaning in the exp (capture)

You should try with \ before those characters, or use the escape function in the re module