0

I'm trying to replace anything after 'databaseDir=' in a config file:

# Config file example
homeDir=c:\Application\home
databaseDir=C:\OldApplication\home

(Get-Content -Path $configFile) -replace "databaseDir=*", "databaseDir=C:\Application\home"

This is not working. I thought * matched any character after databaseDir= How can I fix this?

user9924807
  • 707
  • 5
  • 22
  • 1
    the `-replace` operator is a _regex_ operator. so `*` means `zero or more of the preceding char`. what you likely want is to replace that with `.+` which means `one or more of any character`. – Lee_Dailey Sep 19 '19 at 10:42
  • you can use [\S]* to match Non-whitespace characters – Barkha Sep 19 '19 at 10:51

0 Answers0