Using the substring function to parse out NPA-NXX of phone numbers in records, where sometimes the phone number starts with a "1" (11 characters/digits in length), and sometimes they don't (10 characters/digits in length). Using the following syntax to 1) print my original field and 2) print a substr, starting 10 characters from the END of a the string (negative index), and parse out 6 characters (and even filtering out ONLY for records where there are only 11 characters):
if(length($11)==11){print $11, (substr($11,-10,6))But the results I get have the results starting from the very first characters in the string:
15556667777 155566
I am not sure what I am doing wrong?
In reply to Negative Index with "substr" Not Working by he204035
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |