开发者

how to construct pattern in regular expression

开发者 https://www.devze.com 2023-03-13 23:11 出处:网络
How to generate a regular expression that will scan a full text file (say, sample.txt) and return开发者_StackOverflow中文版 the index of the first occurance of STRT followed by any number of spaces an

How to generate a regular expression that will scan a full text file (say, sample.txt) and return开发者_StackOverflow中文版 the index of the first occurance of STRT followed by any number of spaces and then a. That means it can be like

"STRT   ."

or it can be like

"STRT        ."


Try this: @"STRT\s*\."

the \s* will match any number of whitespace characters and . will match the literal period.

0

精彩评论

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