in reply to Running complex sed from perl
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Running complex sed from perl
by sunglant (Initiate) on Dec 02, 2013 at 02:03 UTC | |
by shmem (Chancellor) on Dec 02, 2013 at 03:29 UTC | |
by sunglant (Initiate) on Dec 02, 2013 at 23:39 UTC | |
by aaron_baugher (Curate) on Dec 02, 2013 at 23:51 UTC | |
by 2teez (Vicar) on Dec 02, 2013 at 05:15 UTC | |
by wazat (Monk) on Dec 02, 2013 at 04:35 UTC | |
|
Re^2: Running complex sed from perl
by sunglant (Initiate) on Dec 02, 2013 at 00:42 UTC | |
|
Re^2: Running complex sed from perl
by sunglant (Initiate) on Dec 01, 2013 at 22:35 UTC |