Here's how I'd go about it:
LOREM_IPSUM = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.".split
STRING = [
'123 123 1234',
LOREM_IPSUM.shift(1 + rand(4)),
'123-123-1234',
LOREM_IPSUM.shift(1 + rand(4)),
'12 123 12345',
LOREM_IPSUM.shift(1 + rand(4)),
'123 1234567',
LOREM_IPSUM.shift(1 + rand(4)),
'123 123456789',
LOREM_IPSUM.shift(1 + rand(4)),
'123 12345',
LOREM_IPSUM.shift(1 + rand(4)),
'1234567',
LOREM_IPSUM.shift(1 + rand(4)),
'1234567890',
LOREM_IPSUM.shift(1 + rand(4)),
'123456789',
LOREM_IPSUM.shift(1 + rand(4)),
'(12)1234567',
].join(' ')
STRING # => "123 123 1234 Lorem ipsum dolor sit 123-123-1234 amet, consectetur adipisicing 12 123 12345 elit, sed do eiusmod 123 1234567 tempor 123 123456789 incididunt ut 123 12345 labore 1234567 et dolore magna aliqua. 1234567890 Ut enim ad minim 123456789 veniam, (12)1234567"
STRING.scan(/\d+.\d+.\d+/) # => ["123 123 1234", "123-123-1234", "12 123 12345", "123 1234567", "123 123456789", "123 12345", "1234567", "1234567890", "123456789", "12)1234567"]
STRING.scan(/\d+.\d+.\d+/).map{ |s| s.gsub(/\D+/, '') } # => ["1231231234", "1231231234", "1212312345", "1231234567", "123123456789", "12312345", "1234567", "1234567890", "123456789", "121234567"]
I removed a couple duplicate formats to simplify the test.
There are a lot of ways that a phone number can be formatted. "A comprehensive regex for phone number validation" is a good starting point for ideas. Based on the comment in the selected answer:
just strip all non-digit characters on input (except 'x')
I figure this is a reasonable starting pattern:
/\d+.\d+.\d+/
Using that with scan
on the test string captures all the sample phone numbers above. Once you have them follow the next piece of advice in that answer:
[...] Then when you display, reformat to your hearts content.