Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Regex in ASP for double quote qualified text file

Status
Not open for further replies.

rlatham

Programmer
Aug 23, 2000
51
US
Hello,

I am trying to use this Regex pattern to read a text file that is comma separated and uses double quote as the text qualifier.
"(.*?)","(.*?)","(.*?)","(.*?)","(.*?)","(\w{2})","(.*?)","(.*?)","(.*?)".*[\r|\n]

I tested it with Expresso and got the results I wanted.

The question is: How do I put this pattern in a variable for ASP?

I have tried many ways, but can't get it right, please help.

The variable would be used as a parameter for a function.

Sample data:
"Mickey & Minnie","","Wilson","123 N Maple Dr","Disney","FL","47304","785","999",,,,,,
"Donald","","Duck","4567 N County Road 650 E","Outdoors","PL","47320","123456","256",,,,,,
"Grommit","","Wallace","741 Michigan Ave, PO Box 87","Dreamworks","TF","46957","365000","456",,,,,,

Thanks in advance,

R.L.
 
Have you tried DOUBLING all of the quotes in the pattern?

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Not that your method won't work, but how about using the text file driver with ADODB?

Here's a recent thread thread333-1237787

barcode_1.gif
 
To translate the pattern used in the ui into vbs for asp, apart from escaping the quote itself by doubling it up, there is multiline setting detail to really get it done. With that setting in place, you can inject more vigor into the pattern with begin-of-line and end-of-line (rather than [\r|\n] which can make you match less than you would like.
[tt]
set rx=new regexp
with rx
.global=true
[blue].multiline=true[/blue]
.pattern="[blue]^[/blue]""(.*?)"",""(.*?)"",""(.*?)"",""(.*?)"",""(.*?)"",""(\w{2})"",""(.*?)"",""(.*?)"",""(.*?)"".*[blue]?$[/blue]"
end with
'with s being the string containing all the data
set cm=rx.execute(s)
for each m in cm
response.write m & "<br />"
for each sm in m.submatches
response.write sb & "<br />"
next
next
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top