Regex replace

Hi,
When I type below command the new value is appended to the existing value;
(Get-Content C:\temp\File.ini) -replace ‘IP_1=*’, (‘IP_1=’+$ip) | Set-Content c:\temp\File.Ini

And when I add a period to the old character value ‘IP_1=.*’ the old value is replaced totally, wanted to know how does period work here?

Thanks,
Kishor

Is it trying to dot source the file? I can’t be sure, but that’s perhaps what its doing, look at

http://www.computerperformance.co.uk/powershell/powershell_syntax.htm#Operators_

Its also used for objects, so maybe it’s doing something funky? Sorry i couldn’t be more help.

-replace works with regular expressions. A period is the meta charachter for “any charachter” and the star/asterisk (*) is the modifier meaning 0 or any number of occurances of the charachter or meta charachter or group right before this meta charachter.

What is it, what you’re trying to accomplish?

Thank you Olaf and Chris.
I am using the command to modify an IP address in the ini file IP_1 = x.x.x.x to IP_1 = y.y.y.y

Thanks,
Kishor

If you’re looking for literal periods with regex you have to “escape” them with a backslash … like this “.