Hi, @dr-ramaanand and all,
Ah…, OK. So I changed my line of reasoning :
Instead of looking for zones which do not contain the string code\x20?{, I’m looking for sections which do contain the string code\x20?{
Then, using the well-known backtracking control verbs (*SKIP)(*F), I omit these cases and look for the string <code, in all the other cases !!
Thus, the following regex should solve your problem :
(?xs-i) <code (?:(?!</style>).)+? </code> (?:(?!</style>).)+? <style\x20 (?:(?!</style>).)*? code\x20?{ .+? </style> (*SKIP) (*F) | <code
Test it against the sample text, below :
<code............>............</code>
<style type="text/css">
code{
font-family: "verdana";
font-size: 19px;
color: black;
font-weight: bold !important;
line-height: 1 !important;
}
}
</style>
<code............>............</code>
<style type="text/css">
</style>
<code............>............</code>
bla blah
bla blah
bla blah
<style type="text/css">
code{
font-family: "verdana";
font-size: 19px;
color: black;
font-weight: bold !important;
line-height: 1 !important;
}
}
</style>
<code............>............</code>
<style type="text/css">
</style>
<code............>............</code>
bla
blah
bla
blah
bla
blah
<style type="text/css"></style>
<code............>............</code>
<style type="text/css">
code {
font-family: "verdana";
font-size: 19px;
color: black;
font-weight: bold !important;
line-height: 1 !important;
}
}
</style>
bla
blah
<code............>............</code>
A lot of text here, spanning many lines
<style type="text/css">
code {
font-family: "verdana";
font-size: 19px;
color: black;
font-weight: bold !important;
line-height: 1 !important;
}
}
</style>
Some text/codes here
<div id="google_translate_element"></div>
<script type="text/javascript">
Some javascript here
</script>
<code............>............</code>
A lot of text here, spanning many lines
<style type="text/css">
</style>
Some text/codes here
<div id="google_translate_element"></div>
<script type="text/javascript">
Some javascript here
</script>
BR
guy038