A
A
Andrey Strelkov2019-02-07 14:06:26
PowerShell
Andrey Strelkov, 2019-02-07 14:06:26

How to beautifully delete certain substrings in a file using Powershell?

Good afternoon, there is a text file (file.txt) with the following content

Diverse and rich experience in the implementation of planned targets contributes to the preparation and implementation of development forms. Thus, the scope and place of personnel training require the definition and refinement of new proposals. We should not, however, forget that the constant information and propaganda support of our activities is an interesting experiment in testing the forms of development. The significance of these problems is so obvious that the further development of various forms of activity entails the process of introducing and modernizing the development model. The task of the organization, in particular the existing structure of the organization, entails the process of implementation and modernization of the corresponding activation conditions. Diverse and rich experience The established structure of the organization entails the process of introducing and modernizing positions,

It is necessary to remove a certain list of substrings, for example, such substrings as:
  • a rich experience
  • clarification of new
  • interesting experiment

And save to the same file changes

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
azarij, 2019-02-07
@strelkovandreyvalerievich

here's how they said above, but with one amendment:
(Get-Content test.txt) -replace "rich experience|clarification of new|interesting experiment" | Set-Content test.txt

A
antonwx, 2019-02-07
@antonwx

(Get-Content test.txt).replace('богатый опыт', '').replace('уточнения новых', '').replace('интересный эксперимент', '') | Set-Content test.txt

(c) first link on google search

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question