开发者

regex for at least 2 empty space?

i开发者_运维技巧 need to ignore anything that is one space, and empty space at least bigger than one space should be matched...

"MARY   HAD A LITTLE            LAMB"

i expect

"MARY", "HAD A LITTLE", "LAMB"


Whitespace matching is \s and you can supply a minimum and maximum in curly braces. You can also omit either of them, like so:

\s{2,}

So your code would be like:

"MARY   HAD A LITTLE            LAMB".split(/\s{2,}/)

You can test it online here!


Use this: str.split(/\s{2,}/)


sed 's/  */ /g'

replaces one or more space..

so i guess regex is,

<space><space>*
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜