regex for html-attributes with json-data

I know use a dom-parser :P but I maybe have only strings and no html-dom, so I try to detect html-attributes from the string, but if there is e.g. a decoded json attribute, then my regex failed. Any ideas how to improve the regex?

$input_lines = 'href="https://mbd.baidu.com/newspage/data/landingsuper?context={"nid":"news_15446515888862039806"}&n_type=0&p_from=1" target="_blank" foo=\'bar\'';

preg_match_all("/\s*[A-Za-z\-]+\s*=\s*(\"|\042|'|\047)([^\1]*?)\1/", $input_lines, $output_array);

var_dump($output_array);

result:

0   =>  array(
    0   =>  href="https://mbd.baidu.com/newspage/data/landingsuper?context={"
    1   =>   target="_blank"
    2   =>   foo='bar'
)
1   =>  array(
    0   =>  "
    1   =>  "
    2   =>  '
)
2   =>  array(
    0   =>  https://mbd.baidu.com/newspage/data/landingsuper?context={
    1   =>  _blank
    2   =>  bar
)

regex-demo: https://regex101.com/r/OylwAO/1

here is the code: https://github.com/voku/anti-xss/blob/master/src/voku/helper/AntiXSS.php#L2211