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
Post a Comment