I have files like the following:
<div title="alpha" Mauris eu justo sed nisi aliquet blandit. <span name="ll">beta</span> Fusce in pharetra nisi. <span name="ll">gamma</span> Aliquam vehicula imperdiet turpis et rhoncus. <span name="ll">delta</span> Donec faucibus augue quis neque dictum, at rutrum dolor placerat.</div>
I try to get the content of nth name="ll" attribute in place of title= content while preserving the order of the rest.
For example, the 2nd name="ll" would get me:
<div title="gamma" Mauris eu justo sed nisi aliquet blandit. <span name="ll">beta</span> Fusce in pharetra nisi. Aliquam vehicula imperdiet turpis et rhoncus. <span name="ll">delta</span> Donec faucibus augue quis neque dictum, at rutrum dolor placerat.</div>
Etcetera.
My try:
find . -type f -exec perl -pi -w -e 's/(title=)"?[^"\s]*"?(.*)((?:.*?\h+class="ll">){1}.*?)\h+class="ll">"?([^"\s]+)"?(<.*)/$1"$3"$2$4/' \{\} \;
Where do I make the mistake?