Suppose there are 3 text files with the following contents:
cat * some text * cat * some text * ".
fox * some text * fox * some text * ".
dog * some text * dog * some text * ".
I have 2 questions:
Is it possible to make such an expression that it finds only the second occurrence of the word, which is always the first in the file?
cat * some text * cat * some text * ".
fox * some text * fox * some text * ".
dog * some text * dog * some text * ".
I need to replace the second occurrence of the word. And replace the first word in translit (I myself doubt that this can be done using only regular expressions).
As a result, I need to get the following file contents:
cat * some text * kot * some text * ".
fox * some text * lisa * some text * ".
dog * some text * sobaka * some text * ".
Is it possible to create a regular expression for this?
\A(\s*(\w+)[\s\S]*?)\2([\s\S]*)->$1KOT$3. - Wiktor Stribiżew