in reply to Re^4: extracting number from string
in thread extracting number from string

I you enclose bits of code in <c> and </c> tags the square brackets you typed will be preserved rather than being taken as some sort of link.

So, [\d.] denotes a character class consisting of digits and a full stop. Note that \d is in itself a character class which is the equivalent of [0-9]. Adding a comma is simplicity itself - [\d.,]. Have a look at perlretut and perlre for further information.

I hope this will be helpful.

Cheers,

JohnGG

Update: As AnomalousMonk points out, I totally forgot to explain the significance of the caret symbol at the start of a character class. Sorry!

Replies are listed 'Best First'.
Re^6: extracting number from string
by AnomalousMonk (Archbishop) on Mar 05, 2009 at 18:29 UTC
    And further, the regex metacharacter  ^ at the beginning of a character set complements the characters specified in the set, so that  [^\d.,] means "any character except a decimal digit, full-stop or comma".