Forum Moderators: coopster

Message Too Old, No Replies

Help - regexp for extracting a string from a larger string

         

bernk

3:16 pm on Apr 5, 2007 (gmt 0)

10+ Year Member



Hello,

I am developing a very basic CMS for a website I'm working on. One of the requirements is for the client to be able to post an image in their news posts, as well as links. I've got the links working (sort of, because I fear the way I have set it up may break images).

Ideally I would like something like BBcode but can't wrap my head around regular expressions.

The easiest thing for the client would be to enter something like [img]http://addresss.to.image/picture.jpg

and

[link]http://www.google.com

The PHP script reading these from the database would then check the body string for any [img] and [link] tags and transform each into actual HTML.

Any help with this would be very, very much appreciated!

whoisgregg

3:30 pm on Apr 5, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld [webmasterworld.com], bernk!

I would take a look at existing open source projects that already have this feature and see how they do it.

Also, a search at your favorite search engine for "bbcode php" should bring up some good results. :)

bernk

3:14 pm on Apr 6, 2007 (gmt 0)

10+ Year Member



Thanks whoisgregg.

You were right, searching for PHP BBcode did in fact turn up some good results. I wasn't searching for the right terms before.