Author Topic: How to take a word from a string?  (Read 282 times)

0 Members and 1 Guest are viewing this topic.

Offline phpSenseiTopic starter

  • i can haz cool title?
  • Addict
  • Posts: 2,808
  • Everybody wants Kung-Fu Fighting
    • View Profile
    • Website Development Company
How to take a word from a string?
« on: July 05, 2009, 04:19:57 AM »
Hello,

wow its been a looooooooooong time since I've been here. Back in the day i use to help out all the noobs lol, but now its time to be helped.

Simple and stupid question

Lets say I have a random sentence everytime a refresh a page, but every sentence will have the word "apple" in there...

ALSO the words apple are in [ b ] bbcodes on purpose.

Code: [Select]
I like eating [b]apples[b] all day long. Because [b]apples[/b] are good.
now i want to know how to delete everything outside the [ b ] [ /b ] tags...

I DONT WANT TO USE EXPLODE! I want to specifically delete everything but preserve any word within the bold tags.
« Last Edit: July 05, 2009, 04:22:55 AM by phpSensei »
"There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies and the other way is to make it so complicated that there are no obvious deficiencies."  — C.A.R. Hoare, The 1980 ACM Turing Award Lecture

Offline thorpe

  • Administrator
  • 'Mind Boggling!'
  • *
  • Posts: 29,255
    • View Profile
Re: How to take a word from a string?
« Reply #1 on: July 05, 2009, 04:38:25 AM »
You'll want to ask your question in the regex board.

Offline phpSenseiTopic starter

  • i can haz cool title?
  • Addict
  • Posts: 2,808
  • Everybody wants Kung-Fu Fighting
    • View Profile
    • Website Development Company
Re: How to take a word from a string?
« Reply #2 on: July 05, 2009, 04:43:28 AM »
You'll want to ask your question in the regex board.

Im so stupid, i forgot about the 4th parameter of the preg_match...

little rusty.

thanks tho. I wont forget to put it there next time;
"There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies and the other way is to make it so complicated that there are no obvious deficiencies."  — C.A.R. Hoare, The 1980 ACM Turing Award Lecture