visual-build-professional

How to replace text infile with regular Expression?


I want to replace a version number by a more current one (i.e. getting it from SVN, which is working fine). For testing purposes I try to replace what I find with something simple, but not even this is working.

This regular expression looks fine (e.g. tested in https://regex101.com/) and correctly matches my version number.

RegEx:

([1-9][0-9]|[0-9])\.([1-9][0-9]|[0-9])\.([1-9][0-9][0-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9]|[0-9])

Text to match (that is not matched):

Title="MyTitle 1.0.0"

According to https://regex101.com/ this should work. But Visual Build cannot find any match and no replacement is done.

I can confirm that file access is working, because Visual Build adds the text "error while replacing" to the specified file.

enter image description here

I'm using Visual Build Professional v10.


Solution

  • I'm not exactly sure what's wrong with your existing regex, but when I've had to do similar replacements I've tried to manufacture a replacement strategy that is a little different - basically to keep the regex as simple as possible. You could try something like this:

    Text or regex to find:

    Title=.*

    e.g., just match the correct line of the file. Don't worry about the existing version number values.

    Text to replace matches with:

    Title="MyTitle %v1%.%v2%.%v3%"

    I'm assuming you have three macros v1, v2, v3 for your version number parts. If you have one for the app title you could obviously insert that there too.