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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replacing asterisk wildcard 1

Status
Not open for further replies.

PeeweeJD

Programmer
May 5, 2003
3
US
Hi,

I have a form that passes search criteria to an asp page for searching purposes through the url. ie:


I have it set up so that I can enter the % wildcard on my form to do wildcard searches.

I would like to be able to use * (asterisk) as a wildcard and have some vbscript in my asp file change * to %.

I am storing all of the search criteria in an array with the following vbscript line:
[tt]set arQueryString = Request.QueryString[/tt]

is there a way to intercept my url string and do a quick search/replace before the array splits up the criteria?
 
You can use the Request.ServerVariables collection to get the URL of a page.

<% URLstring = Request.ServerVariables(&quot;URL&quot;) %>

Or the querystring

<% URLquerystring = Request.ServerVariables(&quot;QUERY_STRING&quot;) %>

More about Request.ServerVariables:

Or you can explicitly select an item from the querystring:

<% QuerystringITEM = Request.Querystring(&quot;customername&quot;) %>

Hope this helps,

BDC.
 
THanks for the reply, but I know how to parse out the varialbles. What I want to know is how to replace a specific character within one of those variables with another character.

I want to be able to change
[tt][/tt]

into
[tt][/tt]

note that the asterix characters have been replaced with percent characters.

Also, I would like to do this in the asp page that recieves the query, ie:
step 1: recieve the search, and assign to a string
2. replace 8 with %
3. split into array for use later
4. other stuff I already know how to do.
 
Sorry to be a pain (and I do greatly appreciate the help).

According to the msdn site for split, the split function returns a one dimensional array. Correct em if I'm wrong, but if I have a one dimensional array I will not be able to call array entries by their name (which I need t be able to do). ex:
[tt]arQueryString(&quot;customername&quot;)[/tt]

Here is what I have so far using the replace function:

[tt]For i=1 to arQueryString.Count
strReplace = arQueryString(i)
strReplace = Replace(strReplace,&quot;*&quot;,&quot;%&quot;)
arQueryString(i) = strReplace
Next[/tt]

I figured I could loop through all entries in the array and do the replace and then put the replaced strings back into the array, but I am getting an error on the line [tt]arQueryString(i) = strReplace[/tt]. The error is &quot;Object doesn't support this property or method&quot; I guess I am going about it the wrong way.

What I am trying to do on that line is to write the &quot;replaced&quot; text back into the array.
 
<%
counter=1
Dim arQueryString()
For each item in request.querystring
ReDim PRESERVE arQueryString(2,counter)
arQueryString(0,counter-1) = item
arQueryString(1,counter-1) = replace(request.querystring(item),&quot;*&quot;,&quot;%&quot;)
response.write(arQueryString(0,counter-1) & &quot;: &quot; & arQueryString(1,counter-1) & &quot;<BR>&quot;)
counter=counter+1
Next
'ArrayCounter holds the number of items in the array
ArrayCounter = counter-1
%>

This will put each item in the querystring into a 2 dimentional array (&quot;name&quot;,&quot;value&quot;) after replacing * with %.

&quot;arQueryString&quot; is the name of the array, you might need to change this if it conflicts with a recordset somewhere.

Is this what you need?

BDC.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top