Results 1 to 2 of 2
  1. #1
    zardos is offline Member
    Join Date
    Jan 2011
    Posts
    8
    Rep Power
    0

    Default parse simple string with regex?

    Hello, am new to java and come from php where we have preg_match_all, but i cant figurout how to do this is java.

    I have this String str = "GET /whatever HTTP/1.1";

    I want to annalyse this string and return to me what ever is inbetween "GET /" and HTTP

    so in this case i whould like to return "whatever"

    whatever could be a word or didgets but not a whitespace.

    Pleas help me with this!
    //Thanks

  2. #2
    Petr's Avatar
    Petr is offline Senior Member
    Join Date
    Jan 2011
    Location
    Russia
    Posts
    620
    Rep Power
    4

    Default

    You can just use String#indexOf and String#lastIndexOf. You can see explain this methods in Java API class String.
    Skype: petrarsentev
    http://TrackStudio.com

Similar Threads

  1. Trying to parse int from string. Need help please.
    By Romally in forum New To Java
    Replies: 4
    Last Post: 11-14-2010, 10:58 PM
  2. Simple Regex
    By Dan0100 in forum New To Java
    Replies: 3
    Last Post: 09-16-2010, 09:45 PM
  3. Replies: 4
    Last Post: 02-22-2009, 05:31 PM
  4. how to Parse int to a string variable
    By raj reddy in forum Java Servlet
    Replies: 10
    Last Post: 01-09-2009, 08:41 PM
  5. how to Parse int to a string variable (pls hlp)
    By raj reddy in forum Threads and Synchronization
    Replies: 5
    Last Post: 06-10-2008, 07:32 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •