0

Hi I'm trying to build a regular expression builder to detect 2 or more spaces or a tab, so (let twoOrMoreSpacesOrTab = /\s{2,}|\t/)

How to build this using a Regex Builder?

I tried this but its not 100% acurate:

ChoiceOf {
    OneOrMore("  ")
    One("\t")
}

The problem here is that is trying to match multiples of 2 white spaces, and I want to consume the whole thing.

Godfather
  • 4,040
  • 6
  • 43
  • 70
  • 1
    Isn't "two or more", "one and one or more"? Like `One(" ")OneOrMore(" ")`? You could create a intermediary `TwoOrMore()` which would be one + oneOrMore? – Larme Feb 09 '23 at 13:00

1 Answers1

1

This might work.

let twoOrMoreSpacesOrTab = Regex {
    ChoiceOf {
        Repeat(2...) {
            One(.whitespace)
        }
        One("\t")
    }
}