indivauth's regex doesn't allow opposite ordering of given and surnames. Consider instead:
use strict; use warnings; undef $/; my $alt = '(?:sur|given)name'; my $content = <DATA>; $content =~ s#([^<]*)(<$alt>.*</$alt>)#$1."<authorfield>".&indivauth($ +2)."</authorfield>\n"#egi; sub indivauth { my ($inline) = @_; $inline =~s#(<$alt>(?:(?!$alt|</au>).)*?</$alt>)#<au>$1</au>#gsi; return "$inline"; } print $content; __DATA__ <surname>Coff</surname>, <givenname>D.,</givenname>, <surname>Coff</su +rname>, <givenname>D.,</givenname> <givenname>D.,</givenname>, <surname>Coff</surname>, <givenname>D.,</g +ivenname>, <surname>Coff</surname>
Prints:
<authorfield><au><surname>Coff</surname></au>, <au><givenname>D.,</giv +enname></au>, <au><surname>Coff</surname></au>, <au><givenname>D.,</g +ivenname></au></authorfield> <authorfield><au><givenname>D.,</givenname></au>, <au><surname>Coff</s +urname></au>, <au><givenname>D.,</givenname></au>, <au><surname>Coff< +/surname></au></authorfield>
In reply to Re: tag a matched text
by GrandFather
in thread tag a matched text
by aakikce
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |