ODBiC Discussion Board

Replacing text with regular expressions

by David Richardson, November 26, 2005 06:41

Hi all!

Haven't been on her in a while, but I'm still hard at work with the excellent ODBScript. I've hit against a problem though.

I'm taking summaries as the first 100 characters of articles. The problem with this is that these articles often contain HTML tags and, since I'm only taking the first 100 characters, these are often missing the closing tag which can throw out the structure of the whole page. I can't really replace the < with the ascii code, as it won't make sense to people. My initial attempt was to do a huge $repl() line, but I've got too many tags to replace. So I thought I'd try regular expressions.

I've got as far as

which identifies the tags, but I can't work out how to replace them in the body text.

Any ideas would be greatly received.


Post Your Reply:

E-mail  optional

HTTP Link: 
Link text: 


Copyright ©1997-2003, Roger Harris. All rights reserved.