0

I am trying to write a swift lint rule that will ignore certain files in my project. Those files either start with Fake or end with Spec.swift.

Example:

Object.swift  
FakeObject.swift  
ObjectSpec.swift  

I only want the regex to match on Object.swift

Using http://rubular.com I was able to get it working with ^(?!Fake).*(?<!Spec).swift

Unfortunately, that doesn't seem to work with swiftlint.

A regular expression that works for excluding files ending in Spec.swift
(.*(?<!Spec).swift)doesn't work on http://nsregularexpression.com. So I'm not sure how swiftlint is doing it.

Randall
  • 14,691
  • 7
  • 40
  • 60
  • 1
    What is your goal? Testing out the nsregularexpression.com or use a regex in a Swift piece of code? If the latter, go and use your regex, `"^(?!Fake).*(?<!Spec)\\.swift$"` – Wiktor Stribiżew Dec 13 '16 at 01:02
  • My goal is to write a swiftlint rule that ignores files that start with Fake or end in Spec. None of these regular expressions work with swiftlint for this purpose. – Randall Dec 13 '16 at 16:16
  • 1
    After checking the Github code, I am afraid that side does not support lookarounds that are perfectly valid in ICU regex flavor that Swift supports. – Wiktor Stribiżew Dec 13 '16 at 23:43

0 Answers0