From: Martin DeMello Date: 2003-09-27T14:48:18+09:00 Subject: Re: regexp needed to split letters from numbers 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. Are you likely to have numbers in the drug's name? Don't forget to include that as a test case if so. The following puts a space before the string of digits immediately preceding " mg" if it doesn't already have one: sub(/(\w)(\d+ mg)/, "#{$1} #{$2}") martin