Assuming the regex conversion was correct. Would the following serve?
#!/bin/perl -p s#\D*(\d{3})\D*(\d{3})\D*(\d{4})#(${1}) ${2}-${3}#s;
sample input
adhjfgl 123ab786YT789034 asdf123ab786YT789034 (123) 786-789034 123ab786YT7890bc 1234567890
output
adhjfgl (123) 786-789034 (123) 786-789034 (123) 786-789034 (123) 786-7890bc (123) 456-7890
In reply to Re: Running complex sed from perl
by wazat
in thread Running complex sed from perl
by sunglant
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |