String and symbol issues !?
Ok all I want to do is take the url for the browser and do a search string on it...simple enough right!? ... HA! ... No I’m not that lucky lol ...seams when I try to use "¬" or any symbol in my url string asp.net can't find it. You see I’m calling my asp page url and adding some parameters to the url which the page takes, dose some working out with and passes back a result, but because I’m passing more then 1 parameter to the url I need to separate the parameters out with a symbol like ¬ which is not commonly used as the parameters I’m passing may contain all other symbols like ? and etc…
When I do :
Code:
Dim myURL As String = Request.Url.ToString()
MsgBox(myURL)
Im not getting the symbols back !?
my code:
Code:
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
' check page isn't been post back from form event procedures
Try
'Get the URL
'the url would look something like :
' http://localhost:3973/Projects/RegularExpressionValidator.aspx?Value1¬Value2¬
Dim myURL As String = New String(Request.Url.ToString())
'Does the URL contain parameters?
Dim FirstParameterStart As Integer = myURL.IndexOf("?")
Dim FirstParameterEnd As Integer = myURL.IndexOf("¬")
Dim FirstParameter As String = ""
Dim SecondParameter As String = ""
FirstParameterStart = FirstParameterStart + 1
'If the URL has parameters, then get them. If not, return a blank string
If FirstParameterStart > 0 and Then
' Get the first Parameter
FirstParameter = myURL.Substring(FirstParameterStart, FirstParameterEnd - 1)
' Get the second Parameter
SecondParameter = myURL.Substring(FirstParameterEnd + 1, myURL.LastIndexOf("¬") - 1)
End If
' When tracing the ulr i get back :
' http://localhost:3973/Projects/RegularExpressionValidator.aspx?Value1Value2
' and NOT :
' http://localhost:3973/Projects/RegularExpressionValidator.aspx?Value1¬Value2¬
MsgBox(myURL.ToString())
Catch ex As Exception
MsgBox(ex.Message.ToString())
End Try
End Sub
Any help welcome :thumb:
Re: String and symbol issues !?
Use URL encode and URL decode.
HTH
HoraShadow
Re: String and symbol issues !?
Hi I have tried your suggestion along with a few other variations like:
Code:
Dim myURL0 As String = New String(Server.UrlDecode(Request.Url.ToString()))
Response.Write(myURL0)
Response.Write("<BR>")
Dim myURL As String = New String(Server.HtmlDecode(Request.Url.ToString))
Response.Write(myURL)
Response.Write("<BR>")
Dim myURL2 As String = New String(Server.HtmlEncode(Request.Url.ToString))
Response.Write(myURL2)
Response.Write("<BR>")
Dim myURL3 As String = New String(Server.UrlDecode(Request.Url.ToString))
Response.Write(myURL3)
Response.Write("<BR>")
Dim myURL4 As String = New String(Server.UrlEncode(Request.Url.ToString))
Response.Write(myURL4)
Response.Write("<BR>")
Dim myURL5 As String = New String(Server.UrlPathEncode(Request.Url.ToString))
Response.Write(myURL5)
Response.Write("<BR>")
None of which can get the ¬ i cant use any other symbol like # or ^ as ¬ is about the only symbol that isn't used as part of the regular expression syntax. Is their no other way to do it maybe ? :confused: :sick:
Re: String and symbol issues !?
What does regex have to do with it? If you're looking for a 'reserved' regex character, you can simply escape it using \. Example, if you want to search for \, use \\.
Why do you want to use odd characters in the querystring anyways?
Re: String and symbol issues !?
Well I’m use a asp page which I call from flash and pass a regular expression syntax too as the first parameter, and a string to validate the regular expression against as the second parameter. Then the code then just dose a simple regular expression validation method against the string which can be anything at all, and returns a true or false value back to flash. As regular expression syntax uses basically every symbol their is and the string can be anything I needed to use something that was rare and unlikely to ever be used in string and that wasn’t part of the regular expression syntax, I found only ¬ symbol is the only one I can use. If I tried to use \ instead is that not ever used in or part of regular expression syntax? :confused: :ehh: