Regex to split at >2 spaces or tabs

javascript, regex

Solution

\s{2,}

You can try in this way...! \s{2,} means 2 or more

I got this idea from this replace post Regex to replace multiple spaces with a single space

Demo: http://jsbin.com/akubed/1/edit

I agree with @Will comment - Add Tab space also

\s{2,}|\t

Problem

I'm trying to create a a regex that matches 2 or more spaces, or tabs, basically a combination of `text.split(" ")` and `text.split("\t")`. How do I create it? My attempt: (but it doesn't work) ``` text.split(new RegExp("[ |\t]")) ``` Edit: This splits at spaces/tabs but I need to split at 2 spaces or more.. ``` text.split("\\s+"); ```

Original source

Related problems