I want to remove 1
with awk
from this regex: ^1[0-9]{10}$
if said regex is found in any field. I've been trying to make it work with sub
or substr
for a few hours now, I am unable to find the correct logic for this. I already have the solution for sed: s/^1\([0-9]\{10\}\)$/\1/
, I need to make this work with awk
.
Edit for input and output example. Input:
10987654321
2310987654321
1098765432123
(awk twisted and overcomplicated syntax)
Output:
0987654321
2310987654321
1098765432123
Basically the leading 1
needs to be removed only when it's followed by ten digits. The 2nd and 3rd example lines are correct, 2nd has 23
in front of 1
, 3rd has a leading 1
but it's followed by 12 digits instead of ten. That's what the regex specifies.