P
Patrick Herber
Hello!
I have some trouble trying to solve a regular expression problem:
I get a file, which looks like this one:
[...]
<w>
<w:r>
<w:c>TEXT ONE</w:c>
</w:r>
</w>
<w>
<w:r>
<w:c>CRITICAL TEXT</w:c>
</w:r>
</w>
<w>
<w:r>
<w:c>ANOTHER TEXT</w:c>
</w:r>
</w>
[...]
When inside the <w:c> Tag I find the text "CRITICAL TEXT", then I have
to remove its whole row starting with the <w> tag to its closing
</w> tag. Inside this <w> Tag also other tags can be present (this
is actually a MS Word File in saved in XML Format) and the text is also
not so clear formatted (it can be on one single line).
My try was to say: find a text, which contains <w> followed by any
characters but not by </w> then followed by CRITICAL TEXT then
followed by any charachters but not by <w> then followed by </w>.
I tried with several patterns but I didn't find the correct one:
$content =~ s/<w>[\s\S]*?(?!<\/w>)CRITICAL
TEXT[\s\S]*?(?!<w>)<\/w>//ig;
$content =~ s/<w>(?!.*?<\/w>)*?CRITICAL
TEXT(?!.*?<w>)*?<\/w>//ig;
Can you pleas help me?
Thanks a lot!
Regards,
Patrick
I have some trouble trying to solve a regular expression problem:
I get a file, which looks like this one:
[...]
<w>
<w:r>
<w:c>TEXT ONE</w:c>
</w:r>
</w>
<w>
<w:r>
<w:c>CRITICAL TEXT</w:c>
</w:r>
</w>
<w>
<w:r>
<w:c>ANOTHER TEXT</w:c>
</w:r>
</w>
[...]
When inside the <w:c> Tag I find the text "CRITICAL TEXT", then I have
to remove its whole row starting with the <w> tag to its closing
</w> tag. Inside this <w> Tag also other tags can be present (this
is actually a MS Word File in saved in XML Format) and the text is also
not so clear formatted (it can be on one single line).
My try was to say: find a text, which contains <w> followed by any
characters but not by </w> then followed by CRITICAL TEXT then
followed by any charachters but not by <w> then followed by </w>.
I tried with several patterns but I didn't find the correct one:
$content =~ s/<w>[\s\S]*?(?!<\/w>)CRITICAL
TEXT[\s\S]*?(?!<w>)<\/w>//ig;
$content =~ s/<w>(?!.*?<\/w>)*?CRITICAL
TEXT(?!.*?<w>)*?<\/w>//ig;
Can you pleas help me?
Thanks a lot!
Regards,
Patrick