开发者

RegExp that matches any String containing "0-9" and "." and "-" and " "

I need t check every line of a file for the following pattern: - 14 Values seperated by an irregular number of spaces. - Values may be negative (-), decimal seperator is a dot followed by maximum one digit - The line ends with several spaces

here is a开发者_开发知识库n example line:

10015 20100501  1    4.6    6.4    8.4   10.5   86.6    4.0   13.0    0.9    6.4    0.0 1007.2                                      

Thanks!


This should do it:

/^(-?\d+(\.\d)?\s+){14}$/

Edit: Start and end tags as added by Gumbo.


Try this regular expression:

/^(-?\d+(\.\d)? +){14}$/m

In multiline mode, the ^ and $ match the start and end of the line respectively. -? is for the optional minus sign, \d+(\.\d)? is for the number with optional single decimal place, and  + (space plus +) is for the separating and trailing spaces. That pattern is then repeated exactly 14 time ((…){14}).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜