> Basically valid formats would be:
> $123
> $ 123
> 123$
> 123 $

This would suggest to me something like:

    $CurrencyRegex = '$|foo|bar|baz';
    $AmountRegex = '[\d.]+';
    $prefixed = qr/    ($CurrencyRegex)  \s*   ($AmountRegex)  /x;
    $postfixed = qr/  ($AmountRegex)   \s*   ($CurrencyRegex)  /x;

    ($currency, $amount) = $input =~ $prefixed or reverse $input =~
$postfixed;

(Sorry if some syntax or escaping is wrong.)


Also, try adding:

    use re "Debug";

Reply via email to