Answer the question
In order to leave comments, you need to log in
How to remove text between words from txt/xml file?
Is it possible to solve such problems with the help of regular expressions, if so, I ask for help.
There is a file split into lines, UTF-8 encoding.
1. From the beginning of the file, you need to delete everything up to the word
<xml_catalog
2. Delete everything between
<catalog>
...
<items>
Answer the question
In order to leave comments, you need to log in
I solved the problem like this:
1. There are always 4 garbage lines in the file, so we just delete the first 4 lines:
(gc source.xml -Encoding UTF8 | select -Skip 4) >out1.xml
(gc out1.xml -Encoding UTF8 | out-string) -replace '(?s)(?<=<catalog>).*?(?=<items>)', '' >out.xml
0. Файл нужно слепить в одну строку
1. ".*<xml_catalog'"
2. "<catalog>.*?<items>"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question