0

So, I have this question here, which has been answered. I'm looking to replicate the marked answer in Java. Is there any way I can do some/most/all of it in Java?

Community
  • 1
  • 1
CodingInCircles
  • 2,565
  • 11
  • 59
  • 84
  • 3
    I don't know. Have you tried it yet? – crush Jan 08 '14 at 22:29
  • 1
    Tried doing it in Java, you mean? I've been looking around for a solution, but nothing I saw does what the grep command does. – CodingInCircles Jan 08 '14 at 22:31
  • 1
    Something like this? http://stackoverflow.com/questions/7062954/extract-sub-string-between-two-certain-words-using-regex-in-java. That would be ideal, except that I need to capture 4 different strings as opposed to only one that the poster of that question is trying to get. – CodingInCircles Jan 08 '14 at 22:34
  • 2
    You could go with http://stackoverflow.com/a/13592567/1266906 – TheConstructor Jan 08 '14 at 22:42
  • 1
    I'll give it a shot. Do you happen to know if it works with partial URLs? As you can see, the URL does not really have a "http://..." in front of it. – CodingInCircles Jan 08 '14 at 22:46
  • @TheConstructor, please make your comment the answer. It worked perfectly. I'll mark it as the right answer. Thanks! :) – CodingInCircles Jan 09 '14 at 00:02

1 Answers1

1

Of course Java can be used to replace grep as seen e.g. in this question.

As you really want extract parameter values from a URL you could e.g. go with this approach, where a simple Java-function returns all parameters and their values as a Map. If you already use a HTTP-related library you may also want to look if they included a similar function.

Community
  • 1
  • 1
TheConstructor
  • 4,285
  • 1
  • 31
  • 52