Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Using a variable in a Powershell search and replace string

$
0
0

Hi

a couple of days ago I posted a question about doing a search and replace with wildcards

Search and repalce with Widcards

I got a swift and very helpful answer but now I need to build on it.

In a text file I wanted to replace all the text between two defined words.  the script I got was this

$text = 'Some Server this bit of text varies Language stuff'
$text -replace '(.*Server) .+? (Language.*)','$1 it will always say this $2'

It works great but now I want to replace "it will always say this" with a variable and I can't figure out the correct grammar to make this happen.

Can anyone help??

Thanks

Alex



Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>