in reply to Problem in String Replacement

I usually use XML::XSH2 for XML manipulation. In this case, something like this might work for you:
open 930168.xml ; register-namespace ce 'http://put-your-namespace-URI-here' ; for /ce:bib/ce:bib-reference/ce:other-ref/ce:textref { my $label = substring-before(.,'),') ; if ($label and xsh:matches($label,'\d{4}$')) { insert element ce:label prepend ../.. ; insert text concat($label, ')') into ../../ce:label[1] ; } } save :b ;
I wrapped the XML chunk into ce:bib, your root element might have a different name. Also do not forget to change the namespace URI.