Jump to content

eregi_replace Question ...


Gordon Werner

Recommended Posts

I have a bunch of code that requires users to enter text.  To avoid certain problems, I restrict the tags they can use to mark up the text ... using bracket tags instead of html tags like

[b]...[/b]

which I then replace at runtime using eregi_replace.

 

this is not a problem for things like bold text ...

 

$description		=	eregi_replace('\[b]([^]]*)\[/b]', '<b>\1</b>', $description);

 

but how do I handle things like bullet lists where I want to let the user only have to enter

[*]

?

 

right now, all I do is this:

 

$description		=	eregi_replace('\[\*]', '<li>', $description);

 

but this makes the XHTML validation fail (no closing </li> tags) ...

 

is there an easy way that I can have the code auto-insert the </li> tag? and how would the above code snippet have to change?

 

Thanks

 

G.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.