Non Greedy Regular Expression in Scripting Engine 5.1

W

Wole

Hi. I really need help with a regular expression in ASP. I need a regex
pattern that will grab a select or textarea tag in an HTML file. If I run
the pattern I should get

<select name="whatever">
<option value="a" selected>A</option>
<option value="b">B</option>
<option value="c">C</option>
</select>

Or

<textarea name="whatever">Here is some text area text</textarea>

I know the following pattern works:

<(select|textarea).*(.|\n)*?</(select|textarea)>

But the problem is my web hosting company is using ASP scripting engine 5.1
which does not support the non greedy delimiter (?). I doubt they are going
to upgrade to 5.5 anytime soon. I'll appreciate it if anyone can give me a
pattern that does the same job but does not use the ? delimiter. Is there a
way I can tweak the pattern above so that it works in ASP scripting engine
5.1? Thanks in advance.
 
E

Evertjan.

Wole wrote on 25 feb 2004 in microsoft.public.inetserver.asp.general:
Hi. I really need help with a regular expression in ASP. I need a
regex pattern that will grab a select or textarea tag in an HTML file.
If I run the pattern I should get

<select name="whatever">
<option value="a" selected>A</option>
<option value="b">B</option>
<option value="c">C</option>
</select>

Or

<textarea name="whatever">Here is some text area text</textarea>

I know the following pattern works:

<(select|textarea).*(.|\n)*?</(select|textarea)>

But the problem is my web hosting company is using ASP scripting
engine 5.1 which does not support the non greedy delimiter (?). I
doubt they are going to upgrade to 5.5 anytime soon. I'll appreciate
it if anyone can give me a pattern that does the same job but does not
use the ? delimiter. Is there a way I can tweak the pattern above so
that it works in ASP scripting engine 5.1? Thanks in advance.

my unintested idea would be:

1 test if the file iss without the "~" character

2 replace all "</select>" with "~"

3 use string <select>[^~]*~

4 replace the "~" in the resulting string with "</select>"

Use a seperate and similar code for <textarea>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top