Skip to main content
The 2024 Developer Survey results are live! See the results

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • As much as I hate Regex, I think it is the way to go in this instance. Commented May 31, 2011 at 11:07
  • 1
    That's why I use it. Not that I can but because I have too. :D Commented May 31, 2011 at 11:08
  • 2
    The question says there can be spaces in the key AND the value... even regexes can't solve that problem.
    – Jon Grant
    Commented May 31, 2011 at 11:13
  • Ah, I missed that bit of the original question. That being the case, you're right and the OP is likely to have to resort to best guesses... Maybe if the keys are from a predefined list of possibilities? Commented May 31, 2011 at 11:21
  • Well it's possible. You could probably then just scan the string and search for the location of the {key}: and then substring it from that location to the next : and then check for any key that is still in the string and replace it. But this seems very "Ugly". Can't you change the Input Format ? Or is it a third party lib? Commented May 31, 2011 at 11:25