using parse for 2Pet3:2 foo bar baz?
Posted: Mon Nov 05, 2007 5:56 pm
I have a file full of lines like this:
Gen1:30 blah blah blah
2Pet3:4 blah blah blah
I want to extract that first word, and split it up as follows:
Gen1:30 becomes ("Gen" "1" "30")
2Pet3:4 becomes ("2Pet" "3" "4")
I've played with parse a bit, but I'm flummoxed on this one.
I've made some progress with this:
(parse ((parse str " ") 0) ":")
Which yields ("Gen1" "30")
Is this a job for (regex)?
UPDATE: I played with regex and got what I needed.
(regex {^(.[[:alpha:]]+)(\d+):(\d+)}) mystring)
Ted
Gen1:30 blah blah blah
2Pet3:4 blah blah blah
I want to extract that first word, and split it up as follows:
Gen1:30 becomes ("Gen" "1" "30")
2Pet3:4 becomes ("2Pet" "3" "4")
I've played with parse a bit, but I'm flummoxed on this one.
I've made some progress with this:
(parse ((parse str " ") 0) ":")
Which yields ("Gen1" "30")
Is this a job for (regex)?
UPDATE: I played with regex and got what I needed.
(regex {^(.[[:alpha:]]+)(\d+):(\d+)}) mystring)
Ted