how to replace text using posix regular expression

Hi all,
my manager wants me to use posix regular expression to replace on text match with another
would you please send me an example since I searched php.net but the syntax I have problem with
thanks in advance
help me if you please

Regards
HG
mediaboxAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TiberiuGalCommented:
hi,
is it the regexp or the php functions part you need help with?
can you send some code example you've tried if any, or the text you want to search?
0
jet-blackCommented:
0
Ray PaseurCommented:
http://weitz.de/regex-coach/  (please ask your manager to consider a donation to keep this excellent service in business).

The exact code you need to use will be determined by the inputs and desired outputs.  Let's consider one simple example.  If you wanted to remove everything but letters and numbers from a string, you could do something like this.

That is about all we can do to help you until we know what your input data strings look like, and what you want for output.

One final thought, you might not want to use REGEX in situations where performance matters.  It can be slow and sometimes the combination of explode() strpos() substr() can give you the same results with less overhead.  Just a thought... ~Ray
// A FUNCTION TO GET A CLEAN STRING OF SPECIFIC LENGTH
function clean_string($str, $len=255)
{
    // LETTERS NUMBERS ONLY
    $regex = "/[^A-Za-z0-9]/";
    $str = trim($str);
    $str = preg_replace($regex, '', $str);
    $str = substr($str,0,$len);
    return $str;
}

Open in new window

0
darianbrCommented:
http://weblogtoolscollection.com/regex/regex.php?page=3 is a great site which teaches you how to use regular expressions.

Use Ray_Paseur function and then apply what you learn from the link to the function.

Very helpful site.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.