My script should look for a comma separated 3 digit version number (eg. 1.2.3)
and replace it with the new version number. The same file has another string which doesnt meet this regex still the script changes it.
Samplefile.txt
"[email protected]"
"e2bf8da9-275a-484d-95a6-7e6b8c0ce0ca"
Replace command portion from the Script:
-replace "\d.\d.\d","2.2.2"
I expect it to give output like this,
"[email protected]"
"e2bf8da9-275a-484d-95a6-7e6b8c0ce0ca" # This string not changed
But it changes the second string too as follows which I didn't intent to
e2bf8da2.2.2a-484d-92.2.2e2.2.2ce0ca
Am I wriitng the regex all wrong. Can someone help please?
.) in a regex is the match-anything meta-character, so\d.\d.\dmatches "a digit followed by any character followed by a digit followed by any character followed by a digit". See Kasra's answer for making the dot a plain dot.