[thelist] CF: Regex Puzzle

Frank framar at interlog.com
Sat Nov 9 04:24:01 CST 2002


I'm trying to figure out the regex that will match everything that is not a
tag, and that is not between two tags. For the life of me, I can't figure
it out. Examples:

         abc123             <- match
         abc<br />123   <- match

         <li>abc</li>      <-don't match


Essentially, I will be using it to wrap a <p> and </p> around everything
that isn't a tag or already wrapped in a tag. So far this one is the
closest one that works

         <cfset PRegEx="([^#chr(10)#]+)">

Match any character that is not a line break. Most greps implicitly stop at
a line break. CF's does, in any case. I follow it up with a simple replace

         #REReplace(StringToConvert, '#PRegEx#', '<p>\1</p>#chr(10)#', 'All')#

This works well, but it will re-paragraph a paragraph, or it will paragraph
a div, or list, etc....

Am I missing something spectacularly obvious?






--
Frank Marion <frank at frankmarion.com>      Tel: 416 825 7488




More information about the thelist mailing list