faker icon indicating copy to clipboard operation
faker copied to clipboard

allow letter range for `helpers.regexpStyleStringParse`

Open xDivisionByZerox opened this issue 3 years ago • 0 comments

This issue represents a todo from our codebase:

https://github.com/faker-js/faker/blob/5ae93a7f51d48b2f2f4999f5cfbd2b4a4a5bb272/src/modules/helpers/index.ts#L244-L245

Currently, it is possible to generate a random number in a string with the regexpStyleStringParse functions. For example faker.helpers.regexpStyleStringParse('[500-15000]') will return a string representing a number between 500 and 15000 (for example '8375').

This should also be possible for characters. For example:

  • faker.helpers.regexpStyleStringParse('[A-Z]') will return an uppercase letter between A and Z ('K')
  • faker.helpers.regexpStyleStringParse('[s-w]') will return an uppercase letter between s and w ('u')
  • faker.helpers.regexpStyleStringParse('[A-Df-t]') will return an uppercase letter between A and D or f and t ('s')

xDivisionByZerox avatar Sep 08 '22 21:09 xDivisionByZerox