开发者

RegEx Quickie Special Selection

开发者 https://www.devze.com 2023-02-01 12:44 出处:网络
Alright, I\'m no pro at RegExpression so can someone give me the reg expression that would select the display() and first_name i开发者_开发百科n the following haystack string?:

Alright, I'm no pro at RegExpression so can someone give me the reg expression that would select the display() and first_name i开发者_开发百科n the following haystack string?:


$Question -> display();
$Person -> first_name;



Use ->\s+(.*);$

>>> re.search(r'->\s+(.*);$', '$Question -> display();').group(1)
'display()'
>>> re.search(r'->\s+(.*);$', '$Person -> first_name;').group(1)
'first_name'
0

精彩评论

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