Example
$s = 'This is a example string with some testing cases \cite{author1,author2,author3}.
Then {another example} \citeauthor{author3,author4} and finally
\citeP{author1} \citesome text{author5} \citesome text with[.]$"{author6}and string completes here.';
$output= preg_replace_callback('/\\\\(cite(?:\w+)?){([^}]*)}/', function($m) {
return preg_replace('/([^,]+)(?:,|$)/' ,'<xref '. $m[1] . ' >$1</xref>', $m[2]); },
$s);
Output:
This is a example string with some testing cases <xref cite="">author1<xref cite="">author2<xref cite="">author3.
Then {another example} <xref citeauthor="">author3<xref citeauthor="">author4 and finally
<xref citep="">author1 \citesome text{author5} \citesome text with[.]$"{author6}and string completes here.
Expected output:
This is a example string with some testing cases <xref cite >author1</xref><xref cite >author2</xref><xref cite >author3</xref>.
Then {another example} <xref citeauthor >author3</xref><xref citeauthor >author4</xref> and finally
<xref citeP >author1</xref> <xref citesome text>author5</xref> <xref citesome text with[.]$">author6</xref>and string completes here.
Question:
/\\\\(cite(?:\w+)?)
- only get group of words. I need to get group of words with space symbols special character everything. What would be the regex