0

echo 8d07\'54.520\"W | awk '{ if ($1 ~ /[-+]?[0-9]*[.]?[0-9]+/) print $1; else print "erro" }'

I'm trying to check if it's a number, but it's no working... I use this same regex in a html input text, and it works.

In this case I was expecting "erro". It's not working.

My final goal is to apply 3 different pattern match to 3 fields $1 $2 $3...

4

1 回答 1

1

不是 100% 确定要求,但您可能需要放置锚点。

$ echo 8d07\'54.520\"W | awk '{ if ($1 ~ /^[-+]?[0-9]+[.]?[0-9]+/) print $1; else print "erro" }'
erro
于 2013-06-26T06:16:55.080 回答