View Full Version : problems with preg_match()

12-05-2010, 10:36 AM
I am having trouble getting my preg_match() to work properly.

Here is the code I have:

define('EBOOK_ROOT', '//millionaire/ebooks.php/');
define('DS', '/');


if(preg_match(EBOOK_ROOT, $url))
$url = str_replace(EBOOK_ROOT.DS,'',$url);

I have been trying to find a good documentation on use of regular expressions in PHP, but havnt really found any

Thanks a lot for the help

12-05-2010, 11:34 AM
So, basically, the RegEx starts with an "special character". In most cases, this is a "/" like yours is. The RegEx ends with it too, and then has an "option" section (ixs etc). An empty RegEx that's case-insensitive would look like: "//i". Now, being a special character, if it appears at any point in the main part of the RegEx, you *MUST* escape it using "\".

To match "/":

To match "/millionaire/ebooks.php":

Or you can change the special character:

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum