[thelist] RegEx/ASP

David McCreath mccreath at ak.net
Fri Dec 14 21:23:24 CST 2001


Good late Friday/early Saturday to you --

We're working on a CMS application for Human Resources to post job 
openings. Teaching these folks to use HTML is not an option, so we're 
trying to make it simple simple.

One thing that we need to give them, though, is an easy way to create 
bulleted lists in job descriptions, so I'm trying to set up a 
delimiter/expression combination.

The delimiters that I'm working with right now are two asterisks and a 
carriage return. So they type this in the textarea of the form:

** This is item one
** This is item two
** This is item three

and I should get this on the output page:

<ul>
<li>This is item one</li>
<li>This is item two</li>
<li>This is item three</li>
</ul>

It's kind of working, but it's only picking up the first occurance of 
the string.

Here's the code:

####
' define some variables and create the RegExp object
    dim RegEx
    dim DescStr
    set RegEx = New RegExp
' define the pattern -- the quotes are just for the VBScript
    RegEx.Pattern = "\*\*\s(.*)\r"
' define the string
    DescStr = trim(rs("JobDesc"))
' run the pattern on the string
' ($1 is used for replacement in VBScript RegEx
' instead of the \1 found in grep)
    DescStr = regEx.Replace(SpecsStr,"<li>$1</li>")
    DescStr = "<ul>" & SpecsStr & "</ul>"
###

And the HTML I get back from that is:

<ul>
<li>This is item one</li>
** This is item two
** This is item three
</ul>

Do I need a loop in there somewhere or is my expression not written 
correctly?

thanks
David

[ why do I think of these things late on Friday? ]





More information about the thelist mailing list