I have the following string, which can be the representation of an HTML or XML, it makes no difference:
<node1>
<node2>Conteudo exemplo</node2>
<node3>Conteudo exemplo</node3>
<node4>Conteudo exemplo</node4>
<node5>
<node6>Conteudo exemplo</node6>
</node5>
</node1>
I need to create a pattern for preg_replace to replace > matches / strong>, that is, only the > characters representing the closing of a childless child tag in the above example will be overwritten.
I'm aware that there are better ways to manipulate documents with this structure, for example using the DOMDocument Class, but in this case I really need to use preg_replace .
Simulating an expected result by replacing the > character with @ :
<node1>
<node2@Conteudo exemplo</node2>
<node3@Conteudo exemplo</node3>
<node4@Conteudo exemplo</node4>
<node5>
<node6@Conteudo exemplo</node6>
</node5>
</node1>