majkinetor / au

Chocolatey Automatic Package Updater Module
GNU General Public License v2.0
227 stars 71 forks source link

Multiline regex not working #163

Open galeksandrp opened 6 years ago

galeksandrp commented 6 years ago

https://github.com/majkinetor/au/blob/b976947bbf473444912acaf95512846c0ee2d66a/AU/Public/Update-Package.ps1#L339 Is it safe to use -Raw?

$fileContent = gc $fileName -Encoding UTF8 -Raw
majkinetor commented 6 years ago

No its not safe. All current regexes would stop working like expected.

BUT, I could probably make it parametrized in this way:

function global:au_SearchReplace {
    @{ 
           search1 = replace1
           options = "Raw"
       }
}
majkinetor commented 6 years ago

The current behavior is documented:

NOTE: The search and replace works on lines, multiple lines can not be matched with single regular expression.

majkinetor commented 6 years ago

FYI, you can make it work now like this: do multine line search and replace inside au_BeforeUpdate.