Results 1 to 5 of 5
  1. #1
    garnaout is offline Member
    Join Date
    Sep 2011
    Posts
    17
    Rep Power
    0

    Default Regular expression

    I am trying to parse a string with this pattern:

    objectA objectId anotherVariable < x y z origin1 origin2>

    I don't care about the first portion, I just want to put the data <....> on one string (including the tokens < and >) - how can I do that in a clean way ?

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,041
    Rep Power
    10

    Default Re: Regular expression

    What have you tried? Recommended reading: Pattern (Java Platform SE 6)
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Diargg is offline Senior Member
    Join Date
    Feb 2012
    Posts
    117
    Rep Power
    0

    Default Re: Regular expression

    This might help too. Decent for looking up regex stuff.

    If you know the format of the line, though, you should ask if you need regex at all. String.split("thingToSplitOn") works very well for this...

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Re: Regular expression

    Um, String#split(...) takes a regex parameter.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    Diargg is offline Senior Member
    Join Date
    Feb 2012
    Posts
    117
    Rep Power
    0

    Default Re: Regular expression

    Derp, I knew that last week. In any case, he shouldn't need to use fancy regex for this. I don't believe "<" is a reserved character.

Similar Threads

  1. Regular Expression Help
    By niketanand in forum Advanced Java
    Replies: 1
    Last Post: 06-24-2011, 05:56 PM
  2. regular expression
    By ehsansad in forum New To Java
    Replies: 8
    Last Post: 03-18-2011, 03:23 PM
  3. Help with regular expression
    By mr.ab18 in forum New To Java
    Replies: 2
    Last Post: 08-06-2010, 11:01 PM
  4. regular expression
    By prof.deedee in forum JDBC
    Replies: 3
    Last Post: 02-19-2010, 12:15 PM
  5. regular expression
    By ras_pari in forum Advanced Java
    Replies: 27
    Last Post: 10-07-2009, 01:25 PM

Posting Permissions

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