A proper litmus test, what's causing the hang in your case?
Regex to me, is pattern finding and abstraction taken to the extreme. I like the challenge
Regex to me, is pattern finding and abstraction taken to the extreme. I like the challenge
Now I am enlightened.
/
(?<=^|[ \t])
(?<currency_prefix_with_space>
(?<currency_prefix>
€|EUR|\$|USD
)
[ \t]?
)?
(?<number>
(?<integral>
-?
\d{1,3}
(?:[\.,]\d{3}|\d*)
)
[\.,]
(?<fraction>
\d{2,3}
)
)
(?<currency_postfix_with_space>
[ \t]?
(?<postfix_or_ending>
(?<currency_postfix>
€|EUR|\$|USD
)
) | (?<ending>
[ \t]|$|\n
)
)/xI would've probably approached it differently, trying to first get the 'inverted' match (i.e. ignore anything that isn't a currency-like pattern) and refine from there. A bit like this one I did a while back, to parse garbled strings that may occur after OCR [0]. I imagine the approach does not translate fully, because it's pattern extraction rather than validation.
The idea of an exclusionary approach sounds interesting as well. I'll have to think about that a bit.