0

In Powershell, how can I replace the following string

"\\10.10.10.5\Program Files (x86)\Foo"

into this:

"C:\Program Files (x86)\Foo"

I need to replace only if \\IP was detected in the beginning of the string

EDIT

The IP can be any IP so it should be detected by some RegEx in the format of \\X.X.X.X

1 Answer 1

1
"\\10.10.10.5\Program Files (x86)\Foo" -replace "\\\\10.10.10.5", "c:"  

after your comment, please try this one :

"\\10.10.10.5\Program Files (x86)\Foo" -replace "\\\\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}", "c:" 
Sign up to request clarification or add additional context in comments.

2 Comments

Will not help, The IP is not hardcoded, and can be any IP
you should have mention that in your question !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.