Match digits in [g]awk
问题 I'm stumped! Trying to write an awk regex to match a string against 11 digits. I've tried: if (var ~ /^[0-9]{11}$/ ) if (var ~ /^([0-9]){11}$/ ) if (var ~ /^([0-9]{11})$/ ) if (var ~ /^[0-9]{11}/ ) # altho I really do need to check the whole str if (var ~ /[0-9]{11}/ ) If I use this.... if (var ~ /^[0-9]+/ ) Then I get a match - but I need to check for exactly 11 digits. 回答1: You described your problem, but didn't tell us your awk version. It is an important information. but this may work for