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.
精彩评论