$myvar =~ /" # First quote
( # Capture text to $1
(?: # Non-backreferencing parentheses
[^?"] # Anything that's not a question mark or quote
| # or
\?[^"] # A question mark not followed by a quote (to allow embedded question marks)
)* # Zero or more
) # End capture
\?"/x; # Followed by a question mark and quote
####
$myvar = q{ abc"def??"ghi?"jkl };
##
##
$myvar = q{ abc"def??"ghi?"jkl };
print "matched <$1>" if
$myvar =~ /" # First quote
( # Capture text to $1
(?: # Non-backreferencing parentheses
(?!\?") # not question quote?
. # ok to inch along
)* # Zero or more
) # End capture
\?"/sx; # Followed by a question mark and quote
##
##
matched