开发者

Regex to find text immediately following 1st occurrence of a word

Say I'm looking at a stream of a web page, and near the top it says About 367 results etc etc. I w开发者_如何学Could like to get the number (of results) following the word About with a regex. Does anyone have an example? Or a bone-head tutorial for that matter? Thanks.


You'll want to capture the first group in for the regex /\bAbout\s+(\d+)/


You can extract the number as follows

About (\d+)

or

About (\d+) results

In both cases the digits will be captured.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜