Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. RegExp Problem

RegExp Problem

Scheduled Pinned Locked Moved Web Development
databaseregexhelptutorialquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Abbas82
    wrote on last edited by
    #1

    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!

    G 1 Reply Last reply
    0
    • A Abbas82

      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!

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      Your pattern looks mighty strange. What is it that you are trying to match, really?

      --- b { font-weight: normal; }

      A 1 Reply Last reply
      0
      • G Guffa

        Your pattern looks mighty strange. What is it that you are trying to match, really?

        --- b { font-weight: normal; }

        A Offline
        A Offline
        Abbas82
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups