开发者

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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜