'oh {hello there' =~ / ([{]{0,1}) # Matches '' (after some backtracking) hello # Matches 'hello' (?(1)\}) # Matches '' /x;