$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