On Sun, Mar 18, 2012 at 21:04, Jimmy <[email protected]> wrote:
> Hi,
>
> I would like to generate a hashmap from a string. The key portions of
> the string  will have some a prefix such as @ to define that they are
> a key. So the following string
>
> "@key1  this is a value  @another-key  and another value @test1 and
> other value"
>
> would get converted to.
>
> { :@key1  "this is a value",  :@another-key  "and another
> value" ,  :@test1 "and other value"}
>
> What's the best way to do this?
> Thanks,
> Jimmy

Things to think about when designing an ad-hoc format:

- How are you handling white space?

Your example seems to indicate that any amount of white space is
allowed and ignored between key and value or value and key, but white
space internal to the value is preserved. I suppose keys will never
contain white space since that's not expressible as the first bit of
white space following the key marks the transition to value.

- Values can't be empty, consist of, start with or end with white space.

- Values can't contain @ unless you provide some kind of escaping convention.

// Ben

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to