RegExp Problem
-
Hello, I am having a little problem with my function to encrypt the query strings....
Function encryptMenu(HTMLstring) Dim objRegExp : Set objRegExp = New RegExp Dim expressionMatch, expressionMatched, strTemp With objRegExp .Pattern = "(\?)[(\w\.\&*)+(\=)[\w\d ]*" .IgnoreCase = True .Global = True End With Set expressionMatch = objRegExp.Execute(HTMLstring) If expressionMatch.Count > 0 Then For Each expressionMatched in expressionMatch strTemp = Right(expressionMatched.value, (Len(expressionMatched.value)-1)) 'Alert strTemp HTMLString = Replace(HTMLString, strTemp, EncryptQS(QSCleanup(strTemp), Salt())) Next 'Alert HTMLString encryptMenu = HTMLString Else 'Response.Write "**" & objRegExp.Pattern & "** was not found in the string: **" & StringToSearch & "**." End If Set objRegExp = Nothing Set expressionMatch = Nothing End Function ' Perform the necessary cleanup to the QueryString. Function QSCleanup(QS) QSCleanup = Replace(QS, "&", "&") End Function
Now, I correctly pick out the query string (everything after the "?"), and for most entries it works fine....However, I have a couple of them that even though I pick out the query string, it doesnt replace the whole thing...for example: noretrieve=true&rptid=jax212&dbcode=2&leasepro_id=1000018528&udb_id=100001.8528&usertype=V becomes... noretrieve=true&rptid=jax212&ENC_QfsJ/OaMUZ1cHMjPnUEM4o8C2+tdI/173ET767CvDXE4CEHmTyc5eWNTwinaV+/lI0K5idTSH32yKg+myuvdjA== it should just be ... ENC_QfsJ/OaMUZ1cHMjPnUEM4o8C2+tdI/173ET767CvDXE4CEHmTyc5eWNTwinaV+/lI0K5idTSH32yKg+myuvdjA== Anybody have an idea as to why this is happening? Thanks! -
Hello, I am having a little problem with my function to encrypt the query strings....
Function encryptMenu(HTMLstring) Dim objRegExp : Set objRegExp = New RegExp Dim expressionMatch, expressionMatched, strTemp With objRegExp .Pattern = "(\?)[(\w\.\&*)+(\=)[\w\d ]*" .IgnoreCase = True .Global = True End With Set expressionMatch = objRegExp.Execute(HTMLstring) If expressionMatch.Count > 0 Then For Each expressionMatched in expressionMatch strTemp = Right(expressionMatched.value, (Len(expressionMatched.value)-1)) 'Alert strTemp HTMLString = Replace(HTMLString, strTemp, EncryptQS(QSCleanup(strTemp), Salt())) Next 'Alert HTMLString encryptMenu = HTMLString Else 'Response.Write "**" & objRegExp.Pattern & "** was not found in the string: **" & StringToSearch & "**." End If Set objRegExp = Nothing Set expressionMatch = Nothing End Function ' Perform the necessary cleanup to the QueryString. Function QSCleanup(QS) QSCleanup = Replace(QS, "&", "&") End Function
Now, I correctly pick out the query string (everything after the "?"), and for most entries it works fine....However, I have a couple of them that even though I pick out the query string, it doesnt replace the whole thing...for example: noretrieve=true&rptid=jax212&dbcode=2&leasepro_id=1000018528&udb_id=100001.8528&usertype=V becomes... noretrieve=true&rptid=jax212&ENC_QfsJ/OaMUZ1cHMjPnUEM4o8C2+tdI/173ET767CvDXE4CEHmTyc5eWNTwinaV+/lI0K5idTSH32yKg+myuvdjA== it should just be ... ENC_QfsJ/OaMUZ1cHMjPnUEM4o8C2+tdI/173ET767CvDXE4CEHmTyc5eWNTwinaV+/lI0K5idTSH32yKg+myuvdjA== Anybody have an idea as to why this is happening? Thanks! -
Your pattern looks mighty strange. What is it that you are trying to match, really?
--- b { font-weight: normal; }
the pattern: "(\?)[(\w\.\&*)+(\=)[\w\d ]*" has been changed to: "(\?)[(\w\.\-\&*)+(\=)[\w\.\-\ ]*" What im trying (and I DO) match is the query string (from the ? to the end of it, which may be a "'")...the reason there are so many other things is that the query string may contain & (not &) as well as "." and "-"...the problem doesnt seem to be with the regular expression, but with the replacement part if I change my code to this then everything works out fine...
For Each expressionMatched in expressionMatch strTemp = Right(expressionMatched.value, (Len(expressionMatched.value)-1)) HTMLString = Replace(HTMLString, expressionMatched.value, "?" & EncryptQS(QSCleanup(strTemp), Salt())) Next