powershell - change line in file -


i trying write powershell script following:

  1. open text file.

  2. find line matches following pattern:

    public interface $a extends interfacename 

    and change to:

    public interface $a extends interfacename<$a> 
  3. save file.

you can read data file using get-content, search match , replace using foreach-object , -replace, , write file using set-content. regular expression can used add code need:

# content file get-content 'c:\path_to_your_file.txt' |  # replace each line if matches pattern foreach-object {$_ -replace "(public interface (\s+) extends interfacename)", ' $1<$2>' } | # save changes file set-content 'c:\path_to_your_file.txt' 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -