Possible Duplicate:
Troubleshooting “preg_replace(): Unknown modifier”
My pattern for detecting the URL is: \b[(http://|https://)]*[www]*[\.]*(\S+\.[a-z]{2,})/* while my replacement pattern is \1\2. It’s not seemingly working, however, as I get this error:
Warning: preg_replace(): Unknown modifier ‘/’ in […][…] on line 1
What am I doing wrong?
Also, if someone could mention how to detect the fact a URL could have multiple periods in it for subdomains (like name.subdomain.canada.gov) how would I detect that infinitely? I know I could have \S*\.* but isn’t that like “there could be another set of subdomains and another period, but not necessarily” what if there’s another sequence of five more subdomains?
My actual usage would be: preg_replace("\b[(http://|https://)]*[www]*[\.]*(\S+\.[a-z]{2,})/*", "\1\2", $text);
PHP Needs an surrounding char to seperate regex modifiers and the regex
i.e.
preg_replace("~yourregex~",...)But there are more errors in your Expression which should be fixed also. You use the [] and () wrong.
A better Expression for a simple ulr matcher could be – for your Special scenario this must be changed to your needs: