Jump to content

Help with preg_match please


kiran14

Recommended Posts

Hi,

 

I don't know much about php. Recently my host updated php version to 5.4 and i function eregi() is deprecated errors, so after some googling, replaced it with preg_match but i am stuck with errors

 

Code:

 

preg_match("^ and", "", $mid_str)

 

Error: Warning: preg_match(): No ending delimiter '^' found

 

Tried the following method but not working

 

preg_match("/^ and/", "", $mid_str)

 

Can you guys help me with correct code?

 

Thanks for looking.

 

Link to comment
https://forums.phpfreaks.com/topic/289658-help-with-preg_match-please/
Share on other sites

 

Also, adding the / delimiters should have gotten rid of the warning. So if it's still not working, then that's a different issue and your code probably wasn't working as intended even with eregi.

 

For starters, you are providing an empty string as the 2nd arg. that is the "source" string to match stuff from, in both eregi and preg_match. Your pattern isn't going to match anything in an empty string..

 

Also, you didn't make the preg_match version case-insensitive (read the sticky link).

 

Beyond that.. you're going to have to provide more details than "not working".

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.