Jump to content


a simple preg_replace help please.


3 replies to this topic

#1 Macintosh

    Young Padawan

  • Members
  • Pip
  • 28 posts

Posted 25 June 2008 - 06:10 PM

Hello..
Im looking for some help.

I want to use preg_replace function to replace the following type of code tags.
<code lang="php"></code>
<code lang="javascript"></code>
<code lang="css"></css>

My question is that, in the above code tags, language (lang) is not always same, how can i use preg_replace with the above code tags to place them with something.

Any help will be very much appreciated.
thanks.

#2 Hayden

    P2L Jedi

  • Members
  • PipPipPip
  • 716 posts
  • Gender:Male
  • Location:Texas

Posted 26 June 2008 - 12:11 AM

You should check out the BBCodeTutorial a few blocks down.

#3 derek.sullivan

    Jedi In Training

  • Members
  • PipPip
  • 341 posts
  • Gender:Male
  • Location:Georgia
  • Interests:preaching, programming, music, friends, outdoors, moves, books

Posted 25 July 2008 - 12:23 PM

Not exactly sure what your asking. can you be a bit more descriptive and more straight foward?

#4 Tirus

    P2L Jedi

  • Members
  • PipPipPip
  • 764 posts
  • Gender:Male
  • Location:Montreal, Canada
  • Interests:Web Design, Programming, Music, Martial Arts

Posted 25 July 2008 - 10:33 PM

im also not entirely sure what you're asking, but if you are hung up on the fact that the language could be any number of them (php, css, javascript, etc), then use a switch function (or an equivalent of IF statements, NOT recommended) to detect which languages you could possibly have, and then preg_replace accordingly...there are a finite limit of cases.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users