This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-11-04
Channels
- # beginners (46)
- # boot (65)
- # cider (8)
- # cljs-dev (5)
- # cljsrn (4)
- # clojure (50)
- # clojure-conj (2)
- # clojure-france (1)
- # clojure-greece (18)
- # clojure-russia (8)
- # clojure-spec (39)
- # clojure-uk (36)
- # clojurescript (36)
- # clr (16)
- # component (2)
- # cursive (6)
- # datascript (3)
- # datomic (31)
- # devcards (2)
- # editors-rus (1)
- # emacs (15)
- # events (2)
- # figwheel (1)
- # funcool (24)
- # garden (3)
- # hoplon (22)
- # instaparse (15)
- # leiningen (3)
- # luminus (4)
- # om (59)
- # onyx (24)
- # overtone (1)
- # pedestal (3)
- # planck (18)
- # prelude (1)
- # protorepl (2)
- # re-frame (5)
- # rum (1)
- # sql (1)
- # uncomplicate (1)
- # untangled (66)
- # vim (18)
- # yada (4)
Hi, I need to parse strings like some text with spaces XXX 12345678 98765 43 222 11
. Here are 3 parts: “some text with spaces”, “XXX 12345678”, and "98765 43 222 11”. While the last part is required, the “XXX 12345678” part is optional and will be considered as text by a naive greedy regex. How could I prevent this with Instaparse?
@seylerius Ok, let’s simplify even more. Two examples: John Doe AGE 50
, Dohn Joe
. An input string contains a name and might contain this age thing. I want to parse those eventually to {:name “John Doe” :age 50}
and {:name “Dohn Joe”}
.
Basically what you need is to have a name token, token, and then a name+age token. You then parse for this: "name-age / name"
Basically, you're saying "if this string can match an age too, do that, otherwise it's just a name"
👍 @seylerius, I guess that’s it 🙂