如何使用正则表达式在2个字符串之间获取字符串,最后一个字符串是&符号

时间:2014-09-16 04:44:41

标签: regex posix

我想使用正则表达式从此字符串中的denomamount中提取游戏标题中的Wild%20Wolf50

我的产品支持“POSIX扩展常规语法(ERE)”“Perl反斜杠序列”

提前致谢!

(denomamount =)*&安培?;得到像

一样的东西
  

“denomamount = 50&安培; showInitialCashier =假安培; denomid = 3311&安培; minbet = 50&安培; parametersFromConfigCall =真安培; nscode = DDI&安培; securetoken = dummyToken&安培; xtautopull”

....

  

“/ TC /播放&安培; COUNTRYCODE = US&安培; skincode = DDI-SKIN1&安培; istournament =假安培; terminalid =安培; gametitle = 野生%20Wolf &安培; buildnumber = R370.D1.0 .F.CL79775_244&安培;音频= ON&安培; UNIQUEID = 11906989&安培; defaultbuyinamount = 1000.0&安培; denomamount = 50 &安培; showInitialCashier =假安培; denomid = 3311&安培; minbet = 50&安培; parametersFromConfigCall =真安培; nscode = DDI&安培; securetoken = dummyToken&安培; xtautopull“

1 个答案:

答案 0 :(得分:0)

通过使用Basic正则表达式(BRE)的sed,

$ sed 's/.*gametitle=\([^&]*\).*denomamount=\([^&]*\).*/\1\n\2/g' file
Wild%20Wolf
50