in reply to $1 and regex

If I understand you well, your input line looks like '3256 nothing special 356216'. In this case it's enough to match digit, non-digit and digit again...

#!/usr/bin/perl while (<>) { print if m/(\d+)\D+(\d+)/; print "$1\n$2\n"; }
The output is:
tm@norad:~$ ./regex_test 123 testing... testing 456 123 testing... testing 456 123 456
UPDATE: after reading next replies...
  1. .+ isn't the best notation - it shouldn't catch next digits after (\d+) but it's not specially safe AIMO, especially makes the code more difficoult to understand
  2. this 'to', whitespaces or other words you mentioned in your problem are covered with \D+ which IMvHO is more universal becouse of catching anything except digits

Greetz, Tom.