I have hundreds of text files with contents of this type (these are.txt content files from Kirby CMS):
Attributes:
- attribute: ''
----
Materials:
-
material: ""
price: 0
available: 'true'
default: 'true'
material_variations:
-
variations:
-
option:
variation: —
price: "0"
variation_available: 'true'
-
option:
variation: ""
price: "0"
variation_available: 'true'
----
Price: 0
I want to remove the part from Materials:
to the next ----
, so the above snippet becomes:
Attributes:
- attribute: ''
----
Price: 0
I am searching for a regular expression to achieve that, but some things that I thought could maybe work (eg \bMaterials\b[^]\b----\b
), produce an error in VSCode.
The [^]
construct only works in the Find and Replace in-document search tool. In the file search tool, Rust regex flavor is used, and [^]
does not work there.
You can use
\bMaterials\b[\w\W]*?----\n*
Details :
\bMaterials\b
- a whole word Materials
[\w\W]*?
- any zero or more chars as few as possible ----
- a literal string of four hyphens \n*
- zero or more line breaks.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.