开发者

Return match position in String.scan

开发者 https://www.devze.com 2023-03-16 08:21 出处:网络
I need to scan larger text documents for patterns expressed in regular expressions and extrac开发者_StackOverflow社区t a certain number of surrounding text tokens. At the moment I use String.scan to r

I need to scan larger text documents for patterns expressed in regular expressions and extrac开发者_StackOverflow社区t a certain number of surrounding text tokens. At the moment I use String.scan to retrieve the matches, but this doesn't give me the position of the matched string in the document. Is there some elegant solution for this?


Check out this post.

It works on a match object. m.begin(1)

0

精彩评论

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

关注公众号