よく使う正規表現のメモ
PHP
$h = '<a href="https://google.com" title="google">Google</a>';
if(preg_match('!<a href="([^"]+)"[\\s\\S]*?>([\\s\\S]*?)</a>!', $h, $m)) {
print_r($m); // ==> Array ( [0] => Google [1] => https://google.com [2] => Google )
}
Nodejs
let h = '<a href="https://google.com" title="google">Google</a>';
let result = /<a href="([^"]+)"[\s\S]*?>([\s\S]*?)<\/a>/.exec(h);
if(result){
console.log(result);
/*
[
'<a href="https://google.com" title="google">Google</a>',
'https://google.com',
'Google',
index: 0,
input: '<a href="https://google.com" title="google">Google</a>',
groups: undefined
]
*/
}