我正在尝试编写一个正则表达式,在这两组字符之间取任何字:
3D
和 &sa
实施例:
3D Evb31p5vFs4_
& sa :输出:Evb31p5vFs4_
3D _Ve8_LBztG50_
& sa :输出:_Ve8_LBztG50_
我使用了表达式:/\w[3D][A-Za-z0-9_-].*sa/g
所以下一步是跳过“3D”和“& sa”
提前致谢!
答案 0 :(得分:3)
您可以将 match()
与正则表达式 pygame.draw.rect(display, black, [50,leady,15,15])
/3D(.*)&sa/
<强>解释强>
var a='3DEvb31p5vFs4_&sa';
var b='3D_Ve8_LBztG50_&sa' ;
document.write(a.match(/3D(.*)&sa/)[1] +'<br>');
document.write(b.match(/3D(.*)&sa/)[1]);
答案 1 :(得分:1)
试试这个:
3D(?s)(.*)&sa
阐释:
3D matches the characters 3D literally (case sensitive)
(?s) Match the remainder of the pattern with the following options:
s modifier: single line. Dot matches newline characters
1st Capturing group (.*)
.* matches any character
Quantifier: * Between zero and unlimited times, as many times as possible, giving back as needed [greedy]
&sa matches the characters &sa literally (case sensitive)
g modifier: global. All matches (don't return on first match)