Page 2 of 2 FirstFirst 12
Results 21 to 22 of 22
  1. #21
    gcalvin is offline Senior Member
    Join Date
    Mar 2010
    Posts
    953
    Rep Power
    5

    Default

    Quote Originally Posted by JosAH View Post
    Why not? A simple "([^=]+)=([^\u0001]+)\u0001" would make a Matcher find the keys as group #1 and their associated values as group #2; if the keys are unique you can stick those pairs in a Map or a Properties object and voila.
    Mostly it's bias on my part. I generally find regexes confusing to read, although you're right that this one is simple enough. Still, with the OP saying he's not so comfortable with regexes, that he needs to handle a high volume of these messages "on the fly" and that he's likely to be interested in fewer than 10% of the keys, I would still prefer my approach. I don't see an advantage to the regex here, either in simplicity or in performance, though I certainly could be mistaken.

    -Gary-

  2. #22
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,354
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by gcalvin View Post
    Mostly it's bias on my part. I generally find regexes confusing to read, although you're right that this one is simple enough. Still, with the OP saying he's not so comfortable with regexes, that he needs to handle a high volume of these messages "on the fly" and that he's likely to be interested in fewer than 10% of the keys, I would still prefer my approach. I don't see an advantage to the regex here, either in simplicity or in performance, though I certainly could be mistaken.

    -Gary-
    A regexp often is overkill but this one (just two transitive closures) finds the patterns in O(n). Of course an indexOf('\u0001') and another one for the equals sign iterating over the entire incoming String can do it equally efficient.

    kind regards,

    Jos

    ps. I don't like regexes much either; they're abused in lots of circumstances.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. image processing
    By sunithamm in forum Advanced Java
    Replies: 6
    Last Post: 12-30-2010, 11:46 AM
  2. Processing help
    By menez in forum Java Applets
    Replies: 3
    Last Post: 02-23-2010, 02:13 AM
  3. Image processing
    By syarizma in forum Advanced Java
    Replies: 6
    Last Post: 08-17-2009, 05:15 AM
  4. image processing
    By sathish natrajan in forum Java 2D
    Replies: 2
    Last Post: 11-06-2008, 05:13 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
  •