note
jonadab
<p>I think you can do this with a single substitution regex (s/pattern/replacement/;), <del>but it's going to need a lookahead assertion at the end</del>. Also, this is only possible if you can write a regex segment that will consistently match the metadata. (Making it match metadata if there is any and not block matching if there isn't any is then trivial: precede the metadata-match portion in <code>(?:</code> and follow it up with <code>)*</code>.</p>
<p>Perhaps something along these lines...</p>
<code>s/(a(?:[<][^>]+[>])*)a((?:[<][^>]+[>])*(?:\s+|[;,.])+)/$1$2/;</code>
<p>That appears to work with the actual sample data you provided, but I don't know if it will work with your real data.</p>
1103362
1103373