1

So according to this answer, it seems that any character can be used to separate query parameters in a URL.

Hence a regex matcher for & delimiter, such as the following, will fail when ; or | or something else is used for example:

private static final Pattern MATCHER = Pattern.compile("name=([^&#]*)");

So is there a GENERIC way of extracting query parameters from a URL, given that ANY valid delimiter could have been used in that URL ?

Shahid
  • 481
  • 1
  • 8
  • 22
Ahmad
  • 12,886
  • 30
  • 93
  • 146
  • Don't write your own parsing code for something the runtime environment provides a parser for. It is very likely to be superior to anything you could write. – Raedwald Sep 25 '18 at 07:05

1 Answers1

1

just change your pattern to '([^&#;|]*)', if you want to deal with ';' and '|'.

Zhang Qi
  • 114
  • 6