I have sentences including letters, integers, and decimals.
Example:
There are 1.6mm, 2.1mmcycst.
There are many about 3mm cysts.
There are 2 cysts about 4~5mm.
("2.1mm cyst" or "2.1 mm scysts" is the accurate sentence, but our data is "2.1mmcycst")
From these sentences, I want to extract numeri's. For example,
1.6 and 2.1
3
4~5
I'm not familiar with regular expressions, and I cannot pick up only numeri's including decimals or other relative signs (eg., "~").
Here is the code:
#!/usr/bin/perl
my $qwe = "There are 1.6mm, 2.1mmcycst.";
print "$qwe\n";
if($qwe =~ /\d+(\.\d)?\d*/){
print "$&\n";
}
From the script, I got below output:
1.6
I am expecting 1.6 and 2.1.
How can I change my regex here to match multiple patterns in single line?
I use macOS 10.14.5 and perl v5.18.4.