datagen icon indicating copy to clipboard operation
datagen copied to clipboard

Generate a string with specified separators

Open php-coder opened this issue 8 years ago • 3 comments

I need to generate a string that could consist from words. I'm trying the following:

length(10).with(oneOf(" ,")).english()

but sometimes it generates strings that start or end with space or comma. I'm looking to a way of avoiding it. Would it be possible to also specify a separator between words?

php-coder avatar Dec 09 '17 01:12 php-coder

Sounds useful. Something like this: length(10).with(wordSeparators()).english()?

ctapobep avatar Dec 09 '17 02:12 ctapobep

Yes. Could be even shorter: length(10).with(separator(" ,")).english()

php-coder avatar Dec 09 '17 13:12 php-coder

Ok, I don't know if I implement this in the nearest future. So in the meantime if this is acceptable, you can try repeaters: repeat(length(10), NUMERIC).string(", ").times(4)

BTW, this separator() can also be implemented outside of the lib. You just need to implement a specific interface.

ctapobep avatar Dec 09 '17 15:12 ctapobep