Jump to content

Please help with eregi "AND"


sastro

Recommended Posts

How to find if a string contain word some words. usualy i used Like this

if(eregi('word1',$str) AND eregi('word2',$str) AND eregi('word2',$str) ...){
.
.
}

 

But it will be eat the CPU resources when to many eregi.

I need a simple solution for this.

 

Thanks

Link to comment
Share on other sites

I would recommend ditching ereg and start learning preg (pcred) instead, as ereg (part of POSIX) is depreciated as of the current stable version (php 5.3) and will no longer be included within the core as of php 6.

 

As for your string, could you show a sample and explain (without regex) what you are trying to match? Otherwise, I'm left making assumptions.

Link to comment
Share on other sites

There's no manual available for pcred()  :(

Is my problem can be resolve with preg_match?

 

Oops.. that will teach me not to post when tired.  :sleeping:

This is what I meant (in line with what Mike tried linking to (but got a 404 Not Found): pcre. Sorry about that.

 

Additional, you can get started on preg by reading these:

 

http://www.regular-expressions.info/

http://weblogtoolscollection.com/regex/regex.php

http://www.phpfreaks.com/forums/index.php/topic,127902.0.html

 

 

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.