Posted to tcl by oldlaptop at Wed Nov 24 06:06:43 GMT 2021view raw
- % set stuff {
- Foo: bar Baz: quux spam ham Egg: bacon bacon baked beans and spam
- Stuff:
- Yada: dada dada dada Florb: nothing
- }
- Foo: bar Baz: quux spam ham Egg: bacon bacon baked beans and spam
- Stuff:
- Yada: dada dada dada Florb: nothing
- % regexp -all -inline {([A-Z][a-z]+): ([^:]+)} $stuff
- {Foo: bar Baz} Foo {bar Baz} {Egg: bacon bacon baked beans and spam
- Stuff} Egg {bacon bacon baked beans and spam
- Stuff} {Yada: dada dada dada Florb} Yada {dada dada dada Florb}
- % lmap {whole_match key value} [regexp -all -inline {([A-Z][a-z]+): ([^:]+)} $stuff] {
- dict set details $key [lrange $value 0 end-1]
- }
- {Foo bar} {Foo bar Egg {bacon bacon baked beans and spam}} {Foo bar Egg {bacon bacon baked beans and spam} Yada {dada dada dada}}
- % puts $details
- Foo bar Egg {bacon bacon baked beans and spam} Yada {dada dada dada}
- % dict get $detail Egg
- bacon bacon baked beans and spam