开发者

Regular expression to extract values

开发者 https://www.devze.com 2023-02-14 14:09 出处:网络
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?

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

精彩评论

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

关注公众号