I am trying to find a way to correctly use Regular Expression (RegEx) to decompose a specific formatted string into 3 values, here are 3 samples of the strings in question.
"1 CASH 1.00 $ 0.21 $"
"1 CASH 1.50 $ 0.22 $"
"1 CASH 10.50 $ 100.50 $"
.. etc ..
This format will never change, my goal is to be able to automatically decompose each string into 3 main fields which represent 1=Type (Cash), 2=Value (1.00), 3=Value (0.21).
So far I was able to generate the following regular expression:
^[0-9]+[ ]+(.+)[ ]+[0-9]+\.[0-9]{2}[ ]+\$[ ]+([0-9]+\.[0-9]{2})[ ]+\$
This splits/decomposes my string into "CASH" and "0.21" (using the first string as an example) whereas I expected (and need) it to be split into 3 values "CASH", "1.00", and "0.21". Why is the "1.00" not picked up? What I am doing wrong? Using the first string as an example I would have expected
Any help, hints, or advice would be greatly appreciated.
(I am using Visual Studios C# 2005)
Thanks,
"1 CASH 1.00 $ 0.21 $"
"1 CASH 1.50 $ 0.22 $"
"1 CASH 10.50 $ 100.50 $"
.. etc ..
This format will never change, my goal is to be able to automatically decompose each string into 3 main fields which represent 1=Type (Cash), 2=Value (1.00), 3=Value (0.21).
So far I was able to generate the following regular expression:
^[0-9]+[ ]+(.+)[ ]+[0-9]+\.[0-9]{2}[ ]+\$[ ]+([0-9]+\.[0-9]{2})[ ]+\$
This splits/decomposes my string into "CASH" and "0.21" (using the first string as an example) whereas I expected (and need) it to be split into 3 values "CASH", "1.00", and "0.21". Why is the "1.00" not picked up? What I am doing wrong? Using the first string as an example I would have expected
Any help, hints, or advice would be greatly appreciated.
(I am using Visual Studios C# 2005)
Thanks,