-1

Ok I wasn't really sure how to word this question, but basically what I want to do is, I got a url from a RSS feed in android, and I need to put part of that url into a string, the url will look something like this: http://www.prsn.uprm.edu/Spanish/Informe_Sismo/myinfoGeneral.php?id=20161206012821and I only want the part after id=, ONLY the number, is that possible? Please help me, Thanks

  • 1
    Check out the answers provided [here](http://stackoverflow.com/questions/13592236/parse-a-uri-string-into-name-value-collection) on how to parse a URI string – dymmeh Dec 09 '16 at 04:53

1 Answers1

2

You can achieve this by using two ways:

    // One Way
    String url = "http://www.prsn.uprm.edu/Spanish/Informe_Sismo/myinfoGeneral.php?id=20161206012821";
    String substr = "=";
    String after = url.substring(url.indexOf(substr) + substr.length());

    // Second Way

    String[] parts = url.split(substr);
    String afterTwo = parts[1];
Reena
  • 1,368
  • 1
  • 11
  • 25