PDA

View Full Version : reg ex question


allida77
04-28-2003, 05:32 PM
I am trying to pull a key value pair from the url.


<%
strQS="&p=asdf&o=asdf&page=11234&p=asdf"
Set qsRegEx = New RegExp
qsRegEx.Pattern = "&page=\d"
qsRegEx.Global = True
newstr = qsRegEx.Replace(strQS,"")
Response.Write(strQS & "<br/>")
Response.Write(newstr)
%>


The problem is how do I get "&page=" plus all the numbers after it until the next "&"? I want to pull "&page=11234" from the QueryString.

oracleguy
04-28-2003, 05:53 PM
Umm, not sure if this works but, try this pattern:
&page=.&

The . character is a universal wildcard that means anything and any length until the next part in the pattern is found.

ReyN
04-29-2003, 02:53 PM
hello

not sure if this is what you meant, but can't you simply use:

Request.QueryString("page")

allida77
04-29-2003, 03:15 PM
I am trying to remove the key-value pair from the QS I ended up using:

strQueryString = Request.ServerVariables("QUERY_STRING")

'remove page= from the querystring
Dim qsRegEx

Set qsRegEx = New RegExp
qsRegEx.Pattern = "&page=\d{" & Len(Request.Querystring("page")) & "}"
qsRegEx.Global = True
strQueryString = qsRegEx.Replace(strQueryString,"")

I tried the "." but couldnt get it to work.