chris_2001 Posted September 20, 2008 Share Posted September 20, 2008 I have a string of text and I need to get what is in the middle of two specific things Hello *wiki black end* everyone! Using the above as an example how would I get php to get only black? Both the words Hello and everyone! will change to random things input by the user. Quote Link to comment Share on other sites More sharing options...
Zane Posted September 20, 2008 Share Posted September 20, 2008 This question is better off in the Regex Forum.. I'll move it for you Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted September 20, 2008 Share Posted September 20, 2008 can you give us a couple examples of what the possibilities are in addition to this one you've showed us? Quote Link to comment Share on other sites More sharing options...
chris_2001 Posted September 20, 2008 Author Share Posted September 20, 2008 Literally anything with some of these tags *vocab *def *wiki *english *spanish end* They are always ended with end*. I want to get the information between the beginning tag (*def etc.) and the end* tag. Here are some random examples. The light of a *wiki black light end* is a weird one In this case I am trying to get "black light" out of the string. *spanish la tarea end* la tarea in this example the first *vocab ionization energy end* is 1923kJ/mol and in this case ionization energy. If you need anything else let me know. Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted September 20, 2008 Share Posted September 20, 2008 You could try <?php $str = 'The light of a *wiki black light end* is a weird one'; $matches = array(); preg_match_all('%\*[a-z]+\s(.*?)\send\*%', $str, $matches); print_r($matches); ?> Quote Link to comment 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.