开发者

PCRE and Whitespace

开发者 https://www.devze.com 2023-02-14 12:57 出处:网络
Using PCRE lib...wanting to look for a string of words up to a known number of whitespace. i.e.5 white space characters between tokens.

Using PCRE lib...wanting to look for a string of words up to a known number of whitespace.

i.e. 5 white space characters between tokens.

foo bar foo bar foo bar = between the first foo and last bar....there are 5 space.

foo     bar = this also has 5 spaces between the first foo and last bar.

开发者_开发知识库

Anyone have the regular expression to find both of these....and variations of spaces?


\S*(\s\S*){N}

where N is the number of whitespace characters you want. Note, also matches a string of N whitespace characters without anything in between them.

0

精彩评论

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