^ # beginning of line
[^|]* # 0 or more any character not pipe
(?! # start negative lookahead, make sure we haven't after:
(?: # start non capture group
\| # a pipe
[^|\r\n]* # 0 or more non pipe, non linebreak
){16} # end goup, must appear 16 times
$ # end of line
) # end lookahead
(?: # start non capture group
\| # a pipe
[^|\r\n]* # 0 or more non pipe, non linebreak
)* # end goup, may appear 0 or more times
$ # ed of line
^[^|]*(?!(?:\|[^|\r\n]*){16}$)(?:\|[^|\r\n]*)*$
. matches newline
解释:
屏幕截图:
为简单起见,我测试了分隔符 <> 3 的数量