ruby - scripting logic : matching patterns -


i trying figure out regex/scripting logic parse out this;

raw data  {clndsdb=medgen:omim:snomed_ct;clndsdbid=c0432243:271640:254100000}   here, value is;       medgen = c0432243      omim = 271640      snomed_ct = 254100000   result: 271640 

i envisaging convoluted if-else loop result. wanted know if there simple way of same result. appreciate answers.

perhaps this: (assuming there 3 fields)

(?<=[=:])(?<key>[^:;]+)(?=[:=;](?:[^:;=]+[=;:]){3}(?<val>[^:]+)) 

the idea capture field values inside lookahead assertion not interfering overlapping substrings.

however, there cleaner way uses successive split.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -