From: Jim Clark Date: 2007-10-26T02:13:11+09:00 Subject: Re: Change a string to an integer, report an error if the st Daniel Waite wrote: > match = '000345'.match(/^\d+$/) # MatchData > match[0] # "000345" > > match = '0003b45aa'.match(/^\d+$/) # nil > match # nil > Integers can also be negative. Not sure if this applies to your case but if so, change the regex to something like: match = '-000345'.match(/^\-*\d+$/) # MatchData match[0] # "-000345" match = '000345'.match(/^\-*\d+$/) # MatchData match[0] # "000345" match = '0003b45aa'.match(/^\-*\d+$/) # nil match # nil Regards, Jim