In the string:
<ut Type="start" Style="external" RightEdge="angle" DisplayText="P id="2""><tr><td width="10%" bgcolor="#C0C0C0" valign="top"><p align="right">2</td><td width="90%"></ut><Tu MatchPercent="100"><Tuv Lang="EN-US"><ut Type="start" RightEdge="angle" DisplayText="csf style="Italic CH" italic="on""><!-- 1 --><FONT COLOR="#FF0000">&lt;csf style="Italic CH" italic="on"&gt;</FONT></ut>Battlefield™ V<ut Type="end" LeftEdge="angle" DisplayText="1"><!-- 1 --><FONT COLOR="#FF0000">&lt;/1&gt;</FONT></ut> (Xbox One)</Tuv><Tuv Lang="NL-NL"><ut Type="start" RightEdge="angle" DisplayText="csf style="Italic CH" italic="on""><!-- 1 --><FONT COLOR="#FF0000">&lt;csf style="Italic CH" italic="on"&gt;</FONT></ut>Battlefield™ V<ut Type="end" LeftEdge="angle" DisplayText="1"><!-- 1 --><FONT COLOR="#FF0000">&lt;/1&gt;</FONT></ut> (Xbox One)</Tuv></Tu><ut Type="end" Style="external" LeftEdge="angle" DisplayText="P"></td></tr></ut>`
I want to replace "
with &quot;
This should only happen if the string is surrounded by FONT tags, like in this case.
I'm using PHP:
$postproc = preg_replace('#(FONT|\G(?!\A))((?!/FONT).*?)"(?!/FONT)#', '$1$2&quot;', $postproc);
This however does not work.
Here we have a similar situation:
$postproc = preg_replace('#(DisplayText="|\G(?!\A))([^">]*)"(?!\s*>)#', '$1$2"', $postproc);
This replaces all " quotes inside DisplayText tags with $quot;
The main difference is that the DisplayText tag ends with one character ("), while the above FONT tag ends with a series of multiple characters, so that I need a negative lookahead instead of the simple [^">]
negation.
I've really tried. For eight hours to be precise. I'm stuck.
$postproc is used on an entire file containing all kinds of tags, amongst which multiple FONT and DisplayText tags as mentioned above, and each tag can contain multiple replacements.