Re: [PHP] preg_match_all

This is a discussion on Re: [PHP] preg_match_all within the PHP General forums, part of the PHP Programming Forums category; * Thus wrote Floris (florisvankempen@home.nl): > hi, > I have this piece of code. but the problem is that ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 09-23-2003
Curt Zirzow
 
Posts: n/a
Default Re: [PHP] preg_match_all

* Thus wrote Floris (florisvankempen@home.nl):
> hi,
> I have this piece of code. but the problem is that he also links parts of
> words (like: credits) and i wnat only standalone words (like: edit)
> Does someone have i idea to correct this piece of code?
>
> Floris
>
> {
> $regex1 = ">[^<]*(";
> $regex2 = ")[^<]*<";
> preg_match_all("/".$regex1.$search_word.$regex2."/i", $string, $matches,


Use the word boundry character:

$regex1 = ">[^<]*\b(";
$regex2 = ")\b[^<]*<";


Curt
--
"I used to think I was indecisive, but now I'm not so sure."
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 11:38 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0