I’m using Clojure to parse and analyze XML files.
Here is a sample:
BSS:17,NSVC:1
BSS:17,NSVC:4
BSS:17,NSVC:5
BSS:17,BTSM:0,BTS:3
BSS:17,BTSM:0,BTS:4
BSS:17,BTSM:0,BTS:5
BSS:17,BTSM:1,BTS:0
BSS:17,BTSM:1,BTS:1
BSS:17,BTSM:1,BTS:2
BSS:17,BTSM:1,BTS:3
I’m interested in that last value (a value after the last comma but before the last : , NSVS and BTS in my case), digits after them don’t matter.
How to extract that last value in the previous strings?
You can use this function to process the individual lines:
NB. this returns
nilif the regex doesn’t match.E.g.:
If you later want to extract all the information in easy-to-work-with bits, you can use
E.g.