![]() | | ||||||||
| | #1 |
| Senior Warrior Member War Room Member Join Date: Oct 2006 Location: , , USA.
Posts: 2,232
Thanks: 8
Thanked 6 Times in 6 Posts
|
Example: I am trying to find all words in a text file ending in "ing" For the life of me, I cannot figure out the pattern for preg_match_all ![]() Please help!! Thanks in advance, Ted |
| TheDiscBuddy.com ~ All New Multi-Item Cart LBLRobot.com ~ Automated Reviews posted for your Business. Last edited by Ted Kopelli; 01-16-2009 at 10:38 AM. Reason: Resolved | |
| | |
| | #2 |
| HyperActive Warrior Join Date: Nov 2005 Location: North West , USA.
Posts: 258
Thanks: 0
Thanked 1 Time in 1 Post
|
found this: int preg_match_all ( string $pattern , string $subject , array &$matches [, int $flags [, int $offset ]] ) Searches subject for all matches to the regular expression given in pattern and puts them in matches in the order specified by flags . After the first match is found, the subsequent searches are continued on from end of the last match. hope it helps! Levada Pendry |
| | |
| | #3 |
| Warrior Member War Room Member Join Date: Dec 2008
Posts: 15
Thanks: 0
Thanked 1 Time in 1 Post
|
I don't know for sure, but try with preg_match("/ing /",$string); |
| | |
| | |
| | #4 |
| Advanced Warrior War Room Member Join Date: May 2004 Location: Perth, Australia.
Posts: 717
Thanks: 4
Thanked 182 Times in 138 Posts
|
The search you are doing sounds a lot like the work thats been done of stemming : Example, thenstem of the word connections is connect, etc Do a quick Google search for Porter Stemming and I'm sure you will find a couple of 1/2 decent PHP classes that will do pretty much what you want.. Also, check out phpclasses.org always a good place to go for code snippets.. Take care Bruce |
| | |
| | #5 |
| HyperActive Warrior Join Date: Jan 2009 Location: Durham, NC
Posts: 144
Thanks: 6
Thanked 25 Times in 18 Posts
|
This code: $text = <<<END The raining in Spain is always remaining on the plain. END; preg_match_all( '/\b([a-zA-Z].*?)ing\b/', $text, $m); produces array m where: array(2) { 0 => array(2) { 0 => string(7) raining 1 => string(9) remaining } 1 => array(2) { 0 => string(4) rain 1 => string(6) remain } } Which is what I think you asked for. And you might have gotten a better response over in the programming topic. |
|
Nothing to see here, move along...
| |
| | |
| | #6 |
| Senior Warrior Member War Room Member Join Date: Oct 2006 Location: , , USA.
Posts: 2,232
Thanks: 8
Thanked 6 Times in 6 Posts
|
Thanks to all I think I have it now. Ted |
| | |
| | |
![]() |
|
| Tags |
| php, question, stupid |
| Thread Tools | |
| |
![]() |