A perfect example for (*SKIP)(*FAIL)
:
"[^"]+"(*SKIP)(*FAIL)|\bor\b
This needs to be replaced by |
, see a demo on regex101.com.
In
PHP
:
<?php
$string = '"Supermajority Vote for State Taxes or fees" or taxes or "ssd or ffF"';
$regex = '~"[^"]+"(*SKIP)(*FAIL)|\bor\b~';
$string = preg_replace($regex, '|', $string);
echo $string;
?>
Which yields
"Supermajority Vote for State Taxes or fees" | taxes | "ssd or ffF"
Broken down, the expression means:
"[^"]+" # everything between "..."
(*SKIP)(*FAIL) # "forget" everything to the left
| # or
\bor\b # or with boundaries on both sides (meaning neither for nor nor, etc.)
As
@mickmackusa points out, you could even use escaped backslahes, see
a demo on regex101.com.