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
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".

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.