Regular expression to extract values
I have this pattern and I need to extract values corresponding to 'key:' and 'value:'. I 开发者_运维技巧have tried a lot of variations for RegExp patterns but no success. Can anyone help me?
[Element Mapping -- Key: 111111111 Value: MyValue - MyName, Element Mapping -- Key: 220002222 Value: My-Val - MyName ].
My expected values are individually:
111111111
MyValue - MyName
20002222
My-Val - MyName
Try this as your regular expression
/Element Mapping -- Key: (\d+) Value: ([^,\]]*)/
http://rubular.com/r/cJLtqCP8j7
Why are you trying to do this with regex?
I would suggest parsing it properly with the same tool that wrote it?
精彩评论