开发者

Easy regular expression

This pertains to a regex expression.If I have a docu开发者_StackOverflow中文版ment with the word Chapter in it how could I select the space right before it?


\s+(?=Chapter)

should do it. \s+ matches space, and (?=Chapter) matches the zero-length string that is followed by the word "Chapter".

For .net, space is defined in http://msdn.microsoft.com/en-us/library/ms972966.aspx thus:

\s Matches any white-space character. Equivalent to the Unicode character classes [\f\n\r\t\v\x85\p{Z}]. If ECMAScript-compliant behavior is specified with the ECMAScript option, \s is equivalent to [ \f\n\r\t\v] (note leading space).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜