I need to modify someone\'s Perl script, and I am not familiar with Perl at all.
There is a scalar variable $var, whose value is a floating point number pos
Following your update, the expression you need is:
^\d+(?:\.\d+)?
^\d+ Match digits at start of string.(?: Start of non capturing group.\.\d+ Match a literal ., followed by digits.)? Close non capturing group making it optional.Check the expression here.
A Perl example:
$var = "123.456.789";
print "old $var\n";
$var =~ /(^\d+(?:\.\d+)?)/;
print "new $1\n";
Prints:
old 123.456.789
new 123.456