Can I perform a Multi-line regex text file substitution?

Comments

1 comment

  • Avatar
    wojciechka

    It is not possible to use the <substitute> action for this. All of the lines are parsed and replaced individually.

    However, you can use <readFile>, <setInstallerVariableFromRegEx> and <writeFile> to perform the same thing. The <setInstallerVariableFromRegEx> action allows performing mapping of multi-line regular expressions.

    <readFile> <name>contents</name> <path>/path/to/file</path> </readFile> <setInstallerVariableFromRegEx> <name>contents</name> <pattern>Multi line replacement</pattern> <substitution>Multiline replacement as single line</substitution> <text>${contents}</text> </setInstallerVariableFromRegEx> <writeFile> <path>/path/to/file</path> <text>${contents}</text> </writeFile>

Please sign in to leave a comment.