From: Robert Retzbach Date: 2006-08-04T14:44:19+09:00 Subject: Re: A little regexp help for a newbie. What about "1a2+b".scan(/\d+) ? It returns the numbers as array. RJ Melton schrieb: > I tried that and it works fine, optimal or not. Thanks. :) > > On 8/3/06, Daniel Baird wrote: >> >> On 8/4/06, RJ Melton wrote: >> > Anyway, I have a simple string in the format 1a2+3 and want to >> basically >> > take out the non-number bits and put the numbers into an array. >> > It also has to match more than single-digit numbers. >> >> I'm pretty sure this is non-optimal, but you could use String.split: >> >> "1a23+4-123".split(/[^\d]/) >> >> the argument to split is a regex that matches anything that's not a >> digit ( \d is a digit; [^\d] is anything but that). split uses that >> argument to decide where to split the string up. >> >> ;D >> >> -- >> Daniel Baird >> http://tiddlyspot.com (free, effortless TiddlyWiki hosting) >> http://danielbaird.com (TiddlyW;nks! :: Whiteboard Koala :: Blog :: >> Things That Suck) >> >> > >