WindStory
WindStory

Reputation: 19

preg_match warning

I have deprecated "eregi" problem.

if (eregi("data/cheditor4[^<>]*\.(gif|jp[e]?g|png|bmp)", $edit_img, $tmp))

So I changed into this,

if (preg_match("/data/cheditor4[^<>]*\.(gif|jp[e]?g|png|bmp)/i", $edit_img,$tmp))

But I got new warmingmessage,

Warning: preg_match() [function.preg-match]: Unknown modifier 'c' 

Please let me know what is wrong.

Thanks in advance.

Upvotes: 0

Views: 114

Answers (1)

mathematical.coffee
mathematical.coffee

Reputation: 56915

You have a '/' inside your regex ('data/cheditor') but you are also using '/' as the regex delimiter ('/myregex/flags'): you can either escape the internal '/', or use a different regex delimiter.

E.g. first option:

preg_match('/data\/cheditor4[^<>]*\.(gif|jp[e]?g|png|bmp)/i',...

or (second option, I chose '@' as the delimiter):

preg_match('@data/cheditor4[^<>]*\.(gif|jp[e]?g|png|bmp)@i',...

Also note I changed the " around your regex to ' because otherwise you need to double the backslashes within double-quotes in PHP.

Upvotes: 3

Related Questions