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 ?
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>