use strict;
my $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.
';
my $regex = qr/\b(\d{3})(\d{3})(\d{4})\b/p;
my $subst = '($1) $2-$3';
my $result = $str =~ s/$regex/$subst/rg;
print "The result of the substitution is' $result\n";
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 Perl, please visit: http://perldoc.perl.org/perlre.html