|
-
Aug 10th, 2005, 02:12 PM
#1
Thread Starter
Addicted Member
Regular Expression with Variables
Hi,
I am trying to do something pretty simple, but i am not sure how to do it with .NET regular expressions. I've used regular expressions in perl alot.
I have an aspx page which i keep on refreshing, and the values can be changed by the user each time it refreshes. However the values that the user puts in do not get saved so what i do is , in my .VB code i do a loop through all the request form values and i search for name equal to that item and i want to replace it with the values. so it will get displayed properly.
how do i search for something using a variable???
here is my code:
VB Code:
For Each item In Request.Form
searchFor = "name=""" & item & """ value="""""
replStr = "name=""" & item & """ value=""" & Request("" & item & "") & """"
TitleInfo.InnerHtml = TitleInfo.InnerHtml.Replace(searchFor, replStr)
Next
my problem is i want to put something like a * in the value.
I want to say any line that says "name=varname value=[ANY VALUE] replace with name=varname value=request(varname).
how do i do that??
ANy help would be grealty appreciated.
-
Aug 10th, 2005, 02:42 PM
#2
Re: Regular Expression with Variables
You could try
TileInfo.InnerHtml = System.Text.RegularExpressions.Regex.Match(TitleInfo.InnerHtml,"name=.+?value="").ToString & Request(item)
-
Aug 11th, 2005, 08:01 AM
#3
Thread Starter
Addicted Member
Re: Regular Expression with Variables
Since there are a few name= value=, i need the regular expression to contain the item variable too. name = item. Can you add that to the example that you gave?
THanks.
-
Aug 11th, 2005, 08:13 AM
#4
Re: Regular Expression with Variables
Regex.Match(TitleInfo.InnerHtml,"name=" & item & "value="").ToString & Request(item)[/QUOTE]
-
Aug 12th, 2005, 10:19 AM
#5
Thread Starter
Addicted Member
Re: Regular Expression with Variables
Does not work.
I get an error:
Regex.Match cannot be converted to string.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|