Combine other answers into a single answer.
Your first format looks right, but your regular expression does not do what you want.
/^[0-9]*$/
matches:
^
: start of line
[0-9]*
: any digit 0 or more times
$
: end of line
So, your regex captures strings that consist solely of numbers. To match fields containing only one or more digits, try using /[0-9]+/
or /\d+/
, which are equivalent, and each of them corresponds to 1 or more digits regardless of the rest of the line.
In total you must have:
if [fieldname] =~ /\d+/ {
source share