I am trying to escape a PCRE in PHP for use in a script. For some reason I can't get it to function when it has been escaped, I've only managed to get it working when the REGEX is given as a form input.
The Regex I'm using is:
$pattern = '£((http|ftp|https):\/\/)?([\w\-_]+(?:(?:\.[\w\-_]+)+))([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?£';
So far I have tried:
preg_quote(): converts the Regex to the following and throws an error: £((http\|ftp\|https):\/\/)\?([\w\-_]+(\?:(\?:\.[\w\-_]+)+))([\w\-\.,@\?\^\=%&:/~\+#]*[\w\-\@\?\^\=%&/~\+#])\?£
htmlentities(): gives error: Warning: preg_match(): Unknown modifier 'a'
addslashes(): same as above
mixture of the 3: same as above
Does anyone have an idea of what I'm doing wrong?