Active Server Pages

Moderators: None (Apply to moderate this forum)
Number of threads: 1751
Number of posts: 4473

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
String manipulation that includes dbl quotes Posted by elcaro2k on 29 Aug 2002 at 6:56 AM
What is the best way to do string manipulations when the string has double quotes. Say if I want to change a SQL where clause into a report header:

(("Health Code" = 'Asthma') AND ("Disease Severity"='Severe))...

into

Health Code = Asthma
Disease Severity = Severe
...

The problem is that the string functions in both js and asp cannot handle the double quotes. Any ideas???

Thanks!


Report
Re: String manipulation that includes dbl quotes Posted by gigsvoo on 30 Aug 2002 at 2:08 AM
:
: (("Health Code" = 'Asthma') AND ("Disease Severity"='Severe))...
:

First of all, are Health Code and Disease Severity fields names?

Please write your complete SQL statement for easier debugging.

Neo Gigs
http://communities.msn.com.my/VisualBasicwithNeo

Report
Re: String manipulation that includes dbl quotes Posted by elcaro2k on 30 Aug 2002 at 4:56 AM
When I get to a point in a Cognos cube, I can do a drill through which sends the query string as part of the URL. I tell Cognos the web page to open but that is the only control I have until it gets to the page. When my page opens I extract the string from the URL by using:

unescape(Request.Form("filter")

which gives a string typical of the one below:

(("Incurred As Of Date" BETWEEN DATE '2001-06-01' AND DATE '2001-06-30') AND ("Health Mgmt Disease Name"='Asthma') AND ("Disease Severity Name"='Mild') AND ("Age Group Name"='5 to 9 years old' AND "Age Group Category Name"='Children') AND ("Gender Code"='MALE') AND ("Region Name" LIKE 'CENTRAL MO OTHER' AND "Region Category Name"='Central MO'))

I then concat this where clause to a SQL statement and go to Oracle to populate my table on the page. I would just like to break this apart to generate a header for the report. The dbl quotes stop me in my tracks when I try to use replace functions and the like.
Report
Re: String manipulation that includes dbl quotes Posted by gigsvoo on 2 Sept 2002 at 6:11 PM
Try to use single quotes?

Neo Gigs
http://communities.msn.com.my/VisualBasicwithNeo

Report
Re: String manipulation that includes dbl quotes Posted by elcaro2k on 3 Sept 2002 at 6:07 AM
Here is the solution that I came up with:


<%@LANGUAGE = VBScript %>
<%Option Explicit%>
<HTML>
<HEAD>


<title>Specialized Drill Through Program</title>
</HEAD>

<BODY bgcolor="#FFFF99">

<H2>The list of parameters passed in was:</H2>
<P>

<left>
<%
dim mytest
dim re
dim patt
dim myarray
dim i
dim testval


set re = new regexp
re.global = true

mytest = Request.Form("filter")

patt = "\x22"
re.Pattern = patt
mytest= re.replace(mytest,"")

patt = "\x29"
re.Pattern = patt
mytest= re.replace(mytest,"")

patt = "\x28"
re.Pattern = patt
mytest= re.replace(mytest,"")

patt = "'"
re.Pattern = patt
mytest= re.replace(mytest,"")

patt = "DATE"
re.Pattern = patt
mytest= re.replace(mytest,"")

patt = "AND"
re.Pattern = patt
mytest= re.replace(mytest,"\")

response.write("<br>")
response.write("<br>")


myarray = split(mytest,"\")
for i = 0 to 3'(split(mytest,"\"))
Response.Write(myarray(i))
Response.write("<br>")
next

%>
</center>
</body>
</HTML>


Report
Re: String manipulation that includes dbl quotes Posted by gigsvoo on 3 Sept 2002 at 6:09 PM
Does that works?

Neo Gigs
http://communities.msn.com.my/VisualBasicwithNeo

Report
Re: String manipulation that includes dbl quotes Posted by elcaro2k on 4 Sept 2002 at 3:59 AM
This message was edited by elcaro2k at 2002-9-4 4:0:35

Yes, remember I am just creating a header for the report (table). I pass the string as I get it from Cognos to Oracle with no changes.



Report
Re: String manipulation that includes dbl quotes Posted by Anjuna Moon on 9 Sept 2002 at 6:40 AM
Why don't you just use ordinary Replace and save some unnecessary code:

str=Replace(str,chr(34),"")

Also, in VBScript when dealing with dbl-quotes you can represent one(1) double-quote as "". In the example above that would be:

str=Replace(str,"""","")

/Chris
Report
Re: String manipulation that includes dbl quotes Posted by elcaro2k on 10 Sept 2002 at 11:02 AM
even better, Thanks!!!




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.