I have a string variable like $string = "'dj12JKmi3433Kl09'"
. How to remove the single quotes '
from the beginning and end of the string using a preg_replace
function? Thanks for your help.
You don't really need a regex for this; you can just use trim()
, as in trim($string, "'")
.
If you really want a regex for some reason, this one would do it:
/^'+|'+$/
Just replace with ''
.