Click to See Complete Forum and Search --> : Regular Expression & Search/Find


codeHermit
11-28-2007, 01:03 PM
I am trying to figure out how to write a regular expression for a certain string and dump the results into a text file. I'm doing a conversion and need to collect ID numbers.

Here are some examples:

ComponentProxy?c=94105
ComponentProxy?c=106077

There are a few thousand of these in a file and I need to take just the ID and put them in a text file so I can then use this to do a select from a database. I've been a web developer for 10 years but I am a newbie when it comes to CREATING regular expressions. The rules of the ID is that they are either a 6 or 7 digit string.

I'm using HomeSite5 to do the find because it has a feature that saves the results to a text file.

Any help would be appreciated!
codeHermit

yearbass
11-29-2007, 11:21 AM
is this useful ?

<%
input_string = "ComponentProxy?c=106077"

dim re
set re = new RegExp
re.pattern = "\d{6,7}"
re.global = true
re.ignorecase = true

dim match
set match = re.execute(input_string)
if match.count > 0 then
response.write match(0).value
else
response.write "no match"
end if

set match = nothing
set re = nothing
%>