ballhogjoni Posted April 28, 2009 Share Posted April 28, 2009 I have a sentence and I want to take a word out of the sentence. what the best way to do that. I am going to use regex, but I don't know which function to use. any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/155941-solved-whats-the-best-way-to-extract-a-string-from-a-string/ Share on other sites More sharing options...
premiso Posted April 28, 2009 Share Posted April 28, 2009 If you want it to be done in regex preg_match is the function to start with. If you want some help, provide an example sentence and the word you want extracted. The key is, what singles that word out. How can you match that word? Is there a certain characteristic that can be used to parse it? Moving to Regex forum for you. Quote Link to comment https://forums.phpfreaks.com/topic/155941-solved-whats-the-best-way-to-extract-a-string-from-a-string/#findComment-820872 Share on other sites More sharing options...
ballhogjoni Posted April 28, 2009 Author Share Posted April 28, 2009 thx Quote Link to comment https://forums.phpfreaks.com/topic/155941-solved-whats-the-best-way-to-extract-a-string-from-a-string/#findComment-820874 Share on other sites More sharing options...
nrg_alpha Posted April 28, 2009 Share Posted April 28, 2009 In addition to what premiso said, sometimes regex is not the best solution for the task at hand. While you have not given any example (to which I invite you to view how to ask a regex question), sounds like you *might* be able to simply use str_replace instead. If it is multiple words, perhaps strtr might be in order...all depends on the example and circumstances. Quote Link to comment https://forums.phpfreaks.com/topic/155941-solved-whats-the-best-way-to-extract-a-string-from-a-string/#findComment-820875 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.