2 Replies Latest reply: May 10, 2007 10:31 AM by 807606 RSS

    Strange regular expression difference when using an URL

      Hello all,

      I took some time and finally was able to come up with a regular expression that express the condition of a parameter in a URL. Baiscally, I want to remove the parameter and everything that belongs to this parameter in the URL so I can construct another link free from this parameter.
      I want it to match either a number(todeletetable=10) or a list of numbers seperated with a comma (todeletetable=10,11,12,13,) in the URL
      I used the following pattern :
      When testing this locally, it works very well.
      String toMatch = "method=allocate&todeletetable=153622,153623,153579,&sortDirection=asc"
      matcher.replaceAll("&") -> returns "method=allocate&sortDirection=asc"
      However, when playing with HTML links, the comma is encoded into %2C. Therefore, I added this expression to the pattern :
      String toMatch = "method=allocate&todeletetable=153622%2C153623%2C153579%2C&sortDirection=asc"
      matcher.replaceAll("&") ->returns "method=allocate&sortDirection=asc" 
      locally but over the web, I get
      It seems that the %2C is not detected in the regular expression in the case of an URL. I don't know what to do to avoid this.
      Please help me if you can with any hint or solution.

      Thank you