vendredi 23 octobre 2020

Is there a framework, Swift Packages package or CocoaPods pod for generating a random string that conforms to a given regex?

I want to generate multiple random strings, each of which must conform to a known regular expression. I am looking to use such a generator in a unit testing suite. I am using Swift 5.2 as the primary programming language to write the tests. Is there a framework, Swift Packages package, CocoaPods pod... or perhaps even just a loose collection of classes/structs/protocols/etc. that I could import and use in an Xcode project to generate these random strings that conform to a provided regex?

The ideal usage I am thinking of would look like this:

let pattern = "^[a-z0-9]{1,2}(aa|bb)$"
let randomConformingStrings = String.generate(numberOfStrings: 100, conformingTo: pattern)



Aucun commentaire:

Enregistrer un commentaire