I need to find and replace a word or expression in a file with my own, of course. For example, I have a file file.xml
:
<title name="Article">Article</title> <title name="article_1">text Article text</title>
I need to replace the word Article
just inside the brackets ><
. I tried working with perl
via cmd
:
perl -p -i -e "s/article/myText/gi" file.xml
but when writing a replacement expression with regular expressions, it turns out that not one word is replaced, but all that I have indicated. I need to replace only one word - article
.
article
with any register (corrected post) by mask. If you put the mask in parentheses, something likes/\s*>\s*article\s*<\s*
, then the whole mask is replaced, and I need to replace only one word. - Sergey Molyak\s*>\s*\Karticle(?=\s*<\s*)
? only the letteri
added afterg
that it would be case insensitive - Mike<title name="Article"myText/title>
instead of the desired<title name="Article">myText</title>
- Sergey Molyak