I just simply want to retrieve two substring of a string which take the following form. The first is a numerical value (there is only one) which is encased between parentheses, such as (12345) – this can be any number of digits (I haven’t really kept any stats on length) but between 1 and 10 digits should cover it. The second substring takes the form of $ some numerical value + $ second numerical value such as ($100 + $5) so again how would I pull that? I have ‘googled’ possible solutions and failed miserably to get something to work so a little explanation might help me learn something…
I forgot to mention that the numeric value can be $100 + $5.20 or $10 + $0.20 or of the form $0.05/$0.10.
Thanks.
If you want to retrieve the two substrings with only one regex you can do, depending of the order the two substrings apear within the original string :
or
If numbers length are between 1 and 10 digit long, you can replace all occurrences of
\d+by\d{1,10}Update :
if you want to match numbers with optional decimal part you have to change
\d+by\d+(?:\.\d\d)?then the regex becomes :