Regex pattern to match text between Single or Double quotes

I need to use PHP regex pattern, that will get the text, placed between quotes. In this case, the text can be placed between single quotes or double quotes. Can you please give me advice, how to make it work and match required content ?
13 Jun 2019 at 05:40 PM
0pnshow more
onefiveonefive
Hi,

This soultion:

if(preg_match("/href=[\"']{1}(.*?)[\"']{1}/im", $text, $v)) {
$content = $v[1];
}


will match text between single quotes:

<a href='https://www.example.com'>Link</a>

and also text between double quotes:

<a href="https://www.example.com">Link</a>
14 Jun 2019 at 03:04 PM
0pnshow more
TimTim
Share on FacebookShare on TwitterShare on LinkedInSend email
Follow us on Facebook & Twitter
2022 AnswerTabsTermsContact us