security - Replace Text using powershell -


i having text file following content:

some text text text text somevariable=334,321;   somevariable=234,234; text b = 34 text text 

i want replace line

somevariable=334,321; 

with

somevariable=10,20;    

i can using following way

 $content.replace("somevariable=334,321;", "somevariable=10,20;")   

but problem somevariable can , want replace values.

$content.replace("somevariable=?,?", "somevariable=10,20;")     

can tell me how can update variable in text file?

use -replace operator, takes regex pattern it's first rhs argument:

$content -replace '(?<=somevariable=)\d+,\d+;','10,20;' 

Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -