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 ?
0
give a positive ratinggive a negative rating
13 Jun 2019 at 05:40 PM
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>
0
give a positive ratinggive a negative rating
14 Jun 2019 at 03:04 PM
Tim
Share on FacebookShare on TwitterShare on LinkedInSend email
x
x
2024 AnswerTabsTermsContact us