How do I write a regex that captures the first non-numeric part of string that also doesn't include 3 or more spaces?

Viewed 385

I'm using Ruby 2.4. I want to extract from a string the first consecutive occurrence of non-numeric characters that do not include at least three or more spaces. For example, in this string

str = "123 aa bb      cc 33 dd"

The first such occurrence is " aa bb ". I thought the below expression would help me

data.split(/[[:space:]][[:space:]][[:space:]]+/).first[/\p{L}\D+\p{L}\p{L}/i]

but if the string is "123 456 aaa", it fails to return " aaa", which I would want it to.

4 Answers
Related