I use perl regex capture groups to replace the pattern of a large number of files.
File example 1:
title="alpha" lorem ipsum lorem ipsum name="beta"
File example 2:
title="omega" Morbi posuere metus purus name="delta"
for
title="beta" lorem ipsum lorem ipsum
title="delta" Morbi posuere metus purus
using
find . -type f -exec perl -pi -w -e 's/title="(?'one'.*?)"(?'three'.*?)name="(?'two'.*?)"/title="\g{two}"\g{three}/g;' \{\} \;
(Note that (1) attribute values of title and name are unknown variables and (2) the content between title="alpha"
and name="beta"
differs. )
I am still learning perl regex. What am I doing wrong?