-2
    id="profile_photo_link" href="/photo83085640_283973341" onclick="return showPhoto('83085640_283973341', 'album8308564
    0_0/rev', 

{temp:{base:"http://cs301701.vk.me/v301701640/",x_:["181d/N_1czOIgH0s",556,313]},

jumpTo:
    {z: 'albums83085640'}}, event)">

<img width="200" height="205" src="http://cs301701.vk.me/v301701640/4a03/mfKV3wOhrqU.jpg
    " alt="Сергей On-line Консультации Василюк">

如何通过 ruby​​ regex 从上面的文本中匹配这个(83085640)数字?正则表达式的开始必须在 showPhoto(' 文本之后并在此点结束 _ 在数字之后

请帮忙!

4

1 回答 1

0

您只需要执行以下操作:

my_text = "showPhoto('83085640_283973341',";    #Input string. I'm only using a part of it here for convenience.
pat = /showPhoto\('(\d*)_/;    #The Regexp pattern as per your requirements.

puts(pat.match(my_text)[1]);

输出:

83085640
于 2013-04-05T06:19:31.870 回答