Go Back   WarriorForum - Internet Marketing Forums > The Warrior Forum > Main Internet Marketing Discussion Forum
Register Blogs FAQ Social Groups CalendarHelp Desk

Reply
 
LinkBack Thread Tools
Old 01-15-2009, 06:25 PM   #1
Senior Warrior Member
War Room Member
 
Join Date: Oct 2006
Location: , , USA.
Posts: 2,232
Thanks: 8
Thanked 6 Times in 6 Posts
Default Stupid PHP Question RESOLVED:CLOSED Thanks

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


Last edited by Ted Kopelli; 01-16-2009 at 10:38 AM. Reason: Resolved
Ted Kopelli is offline   Reply With Quote
Old 01-15-2009, 06:36 PM   #2
HyperActive Warrior
 
Levada's Avatar
 
Join Date: Nov 2005
Location: North West , USA.
Posts: 258
Thanks: 0
Thanked 1 Time in 1 Post
Default Re: Stupid PHP Question

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
Levada is offline   Reply With Quote
Old 01-15-2009, 06:47 PM   #3
Warrior Member
War Room Member
 
Join Date: Dec 2008
Posts: 15
Thanks: 0
Thanked 1 Time in 1 Post
Default Re: Stupid PHP Question

I don't know for sure, but try with
preg_match("/ing /",$string);

aGor is offline   Reply With Quote
Old 01-16-2009, 08:30 AM   #4
Advanced Warrior
War Room Member
 
Bruce Hearder's Avatar
 
Join Date: May 2004
Location: Perth, Australia.
Posts: 717
Thanks: 4
Thanked 182 Times in 138 Posts
Social Networking View Member's Twitter Profile  View Member's YouTube Profile
Contact Info
Send a message via Skype™ to Bruce Hearder
Default Re: Stupid PHP Question

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
Bruce Hearder is offline   Reply With Quote
Old 01-16-2009, 08:58 AM   #5
HyperActive Warrior
 
Join Date: Jan 2009
Location: Durham, NC
Posts: 144
Thanks: 6
Thanked 25 Times in 18 Posts
Social Networking View Member's FaceBook Profile  View Member's YouTube Profile
Contact Info
Send a message via AIM to ltdraper Send a message via Skype™ to ltdraper
Default Re: Stupid PHP Question

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...
ltdraper is offline   Reply With Quote
Old 01-16-2009, 10:38 AM   #6
Senior Warrior Member
War Room Member
 
Join Date: Oct 2006
Location: , , USA.
Posts: 2,232
Thanks: 8
Thanked 6 Times in 6 Posts
Default Re: Stupid PHP Question

Thanks to all I think I have it now.

Ted

Ted Kopelli is offline   Reply With Quote
Reply

  WarriorForum - Internet Marketing Forums > The Warrior Forum > Main Internet Marketing Discussion Forum

Tags
php, question, stupid

Thread Tools

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 On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -6. The time now is 10:30 AM.