0

How can I get one specific uri parameter from an URL? For example my url

/search?q=foo&oq=bar&aqs=chrome&client=android&sourceid=chrome-mobile&ie=UTF-8

Now I want only return the q parameter (foo). My solution was to try it with a substring till indexOf & but there is a problem, if I try the same on an url without an & character.

Need to do it without a special lib, need it for kibana w/ painless.

jonny
  • 9
  • 6
  • may be this `https://stackoverflow.com/questions/11733500/getting-url-parameter-in-java-and-extract-a-specific-text-from-that-url` will be useful. – Doctor Who Jan 17 '19 at 17:58
  • https://stackoverflow.com/questions/13592236/parse-a-uri-string-into-name-value-collection – logger Jan 17 '19 at 17:59
  • thanks guys, [this one](https://stackoverflow.com/a/23623364/1133346) helped me to solve my problem. :) – jonny Jan 18 '19 at 09:59

1 Answers1

0

Found my solution now here.

Similar to my solution but end = (end == -1 ? url.length() : end); helped me to eliminate the remaining error.

jonny
  • 9
  • 6