in reply to Promiscuously match what might be prices

This is not difficult at all. You'll likely want to make a short test script testing various strings against your $promiscuous_proce with Test::More::like.

use Regexp::Common; my $promiscuous_price = qr/ (?: $RE{num}{real} | $RE{num}{real}{-sep => ','} | ... ) /x

⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

Replies are listed 'Best First'.
Re^2: Promiscuously match what might be prices
by tphyahoo (Vicar) on Apr 10, 2006 at 16:03 UTC
    Thanks diotalevi. I think your suggestion will be fine. I just didn't read the manual carefully enough.

    I wound up with

    my $promiscuous_price = qr/ (?: $RE{num}{real} #matches 123456.78 | $RE{num}{real}{-radix => qr/[.]/}{-sep => qr/[,]/} #matches 123, +456.78 | $RE{num}{real}{-radix => qr/[,]/}{-sep => qr/[.]/} #matches 123. +456,78 ) /x;

      Unless you really need it, you should prefer saying \, and \. to [.] and [,]. You're disabling some important optimizations when you move literal text into a character class. Perl doesn't recognize that a single character class is equivalent to a literal character and this prevents its Boyer-Moore string matching from working effectively. That's one of the things that helps to make perl's regex so legendarilly fast.

      ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊