user113709
user113709

Reputation:

Replace words from querystring with Regular Expressions

the string is = "Reg.asp?q=RG_Price=5000*8000,Activated=1"

and i want to replace "RG_Price=5000*8000" with that "Price BETWEEN 5000 AND 8000".

Is that possible with Regular Expressions in ASP ?

Upvotes: 2

Views: 1380

Answers (2)

Gumbo
Gumbo

Reputation: 655509

I would use this regular expression:

^[^?]*\?(?:[^&]*&)*q=RG_Price=(\d+)\*(\d+)

and replace the match with "Price BETWEEN $1 AND $2".

But I don’t know ASP.NET so I cannot give you a working example.

Upvotes: 0

brien
brien

Reputation: 4440

Sure (now with VBScript instead of C#):

Dim queryString, replacedString
Set regEx = New RegExp
regEx.Pattern = ".+RG_Price=(\d+)\*(\d+).*"

replacedString = regEx.Replace(queryString, "Price BETWEEN $1 AND $2")

Upvotes: 2

Related Questions