From: dblack@... Date: 2003-09-27T20:20:43+09:00 Subject: Re: regexp needed to split letters from numbers Hi -- On Sat, 27 Sep 2003, Thomas A. Reilly wrote: > I would appreciate it if someone could give me the regexp that it would > split the following: > for example - > "clonidine300 mg" into "clonidine 300 mg" > > I have a bunch of drug data where the dose had been typed together. Just to add to the list of ideas: in 1.8.0 you can use scanf: irb(main):016:0> require 'scanf' => false irb(main):017:0> str = "clonidine300 mg" => "clonidine300 mg" irb(main):018:0> name, dose, unit = str.scanf('%[\D]%d%s') => ["clonidine", 300, "mg"] the advantage of which is that it turns your dosage into an integer rather than a string. (But it doesn't handle the case where there are digits in the drug name.) David -- David Alan Black home: dblack@superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav