Is it possible to create a regex that will only match a value if it is not preceded by another value? For example, only test true if ? is not preceded by .php. Like the following:
/(?!\.php)\?/.test( 'mypage.php?call=here' ) == false;
/(?!\.php)\?/.test( 'otherpage.asp?call=here' ) == true;
I’ve tried using the lookaheads ?! and ?:, but so far haven’t been able to find a combination that works.
This will match strings that either do not have a
?in them, or have a?that is not preceeded by.php:And here is a version that will also require a
?to be in the string: