正则表达式提取值

时间:2011-03-04 05:15:40

标签: java regex pattern-matching

我有这种模式,我需要提取对应于'key:'和'value:'的值。我已经为RegExp模式尝试了很多变化,但没有成功。任何人都可以帮助我吗?

 [Element Mapping -- Key: 111111111 Value: MyValue - MyName, Element Mapping -- Key: 220002222 Value: My-Val - MyName ].

我的预期价值是单独的:

111111111
MyValue - MyName
20002222
My-Val - MyName

2 个答案:

答案 0 :(得分:1)

将此作为正则表达式

/Element Mapping -- Key: (\d+) Value: ([^,\]]*)/

http://rubular.com/r/cJLtqCP8j7

答案 1 :(得分:0)

为什么要尝试使用正则表达式?

我建议使用编写它的相同工具正确解析它吗?