我有一个具有以下值的字符串:
总到期报表$240.05911 费用$10.00特许经营税$.172VS销售税$.53本地税$.23服务折扣-$50.00付款-谢谢-$100.00HBO+STARLET$100.00
我需要将此字符串拆分为键/值对。
TOTAL DUE-STATEMENT $240.05
911 Fee $10.00
FRANCHISE TAX $.17
2VSALES TAX $.53
LOCAL-TAX $.23
SERVICE DISCOUNT -$50.00
PAYMENT - THANK YOU -$100.00
HBO+STARLET $100.00
我的字符串值将始终是动态的,并且描述是动态的,除非911 Fee
我编写了如下的正则表达式。
([911 a-zA-Z |911 a-zA-Z|a-zA-Z |a-zA-Z \\-? a-zA-Z|! ?|+? ]+)(-?\\$[0-9|,]*\\.[0-9][0-9])
我得到了正确的键/值对,除了描述包含数字、字母和特殊字符。我的输出如下:
TOTAL DUE-STATEMENT $240.05
911 Fee $10.00
FRANCHISE TAX $.17
SALES TAX $.53 ** Which is wrong**(Expected is 2VSALES TAX as key)
LOCAL-TAX $.23
SERVICE DISCOUNT -$50.00
PAYMENT - THANK YOU- $100.00 "-" is coming as key (Expected is PAYMENT - THANK YOU)
STARLET $100.00 **- Which is wrong** (Expected is HBO+STARLET)
有人可以帮我在这个正则表达式中改变什么吗?