re = /\b(\d{3})(\d{3})(\d{4})\b/
str = 'reformat several 10-digit numeral strings to telephone number format
Hello. I\'m looking for regex to use with LibreOffice Calc find-and-replace function to format 10-digit numbers into telephone number format. Example: reformat
4018286606 to be (401) 828-6606
I tried this:
FIND (\\[0-9\\]{10})
REPLACE WITH \\^(\\\\(\\[0-9\\]{3}\\\\)\\\\s\\[0-9\\]{3}-\\[0-9\\]{4})
Not working.
Using LibreOffice [25.8.4.2](http://25.8.4.2)
Thank you.
'
subst = '($1) $2-$3'
result = str.gsub(re, subst)
# Print the result of the substitution
puts result
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html