Regex code from WWDC sample code not working

If I past the samele code

import RegexBuilder
let fieldSeparator = /\s{2,}|\t/
let transactionMatcher = Regex {
  /CREDIT|DEBIT/
  fieldSeparator
  One(.date(.numeric, locale: Locale(identifier: "en_US"), timeZone: .gmt))
  fieldSeparator
  OneOrMore {
    NegativeLookahead { fieldSeparator }
    CharacterClass.any
  }
  fieldSeparator
  One(.localizedCurrency(code: "USD").locale(Locale(identifier: "en_US")))
}

It does not like the OneOrMore with the negative look ahead. Is there an updated example of this code from WWDC?

Post not yet marked as solved Up vote post of venturabumm Down vote post of venturabumm
1.1k views

Replies

Try

  • Lookahead(fieldSeparator, negative: true)