From: Jim Freeze Date: 2003-09-27T12:47:19+09:00 Subject: Re: regexp needed to split letters from numbers On Saturday, 27 September 2003 at 12:44:11 +0900, Jim Freeze wrote: > On Saturday, 27 September 2003 at 12:17:19 +0900, 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. > > There's probably more than one way to do this. Here's one way: > And yet another way: rb(main):018:0> m = /(\w+?)(\d+)\s+(\w+)/.match(s) => # irb(main):019:0> m[1] => "clonidine" irb(main):020:0> m[2] => "300" irb(main):021:0> m[3] => "mg" -- Jim Freeze ---------- "There is no reason for any individual to have a computer in their home." -- Ken Olson, President of DEC, World Future Society Convention, 1977