Generate RandomString from a set of characters

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Generate RandomString from a set of characters

Philippe Mouawad-2
Hello,
Is it possible in commons-text or commons-lang to generate a Random String
from:

- Either a range of characters defined in a regex ? [a-z][0-9] for example
- Either following a pattern (https://github.com/mifmif/Generex)


Thanks
Regards
Reply | Threaded
Open this post in threaded view
|

Re: Generate RandomString from a set of characters

Bruno P. Kinoshita-3
Hi Philippe,
I believe the Random String generators are using a random number generator, combined with some logic for generating codepoints.
But I can see the point for allowing it to generate regular expressions too. Might be useful to allow users to generate text from a regular expression too. Could you file an issue in JIRA for that?
Perhaps someone will volunteer to work on this. I would start by looking at the Builder in RandomStringGenerator, and at the TextRandomProvider interface. Perhaps you could create your own, using Generex, and send us the example to include in the website documentation?
I normally use [text] random string generator, or java faker [1]. However, I don't think java faker provides random values based on regular expressions.
Hope that helpsBruno
[1] https://github.com/DiUS/java-faker

      From: Philippe Mouawad <[hidden email]>
 To: Commons Users List <[hidden email]>
 Sent: Monday, 23 October 2017 7:34 AM
 Subject: Generate RandomString from a set of characters
   
Hello,
Is it possible in commons-text or commons-lang to generate a Random String
from:

- Either a range of characters defined in a regex ? [a-z][0-9] for example
- Either following a pattern (https://github.com/mifmif/Generex)


Thanks
Regards


   
Reply | Threaded
Open this post in threaded view
|

Re: Generate RandomString from a set of characters

Pascal Schumacher
Am 23.10.2017 um 05:29 schrieb Bruno P. Kinoshita:
> However, I don't think java faker provides random values based on regular expressions.
By the way java faker can provide random values based on regular
expressions:

new Faker().regexify(String regex)

It uses Generex to archive this.

Cheers,
Pascal

Reply | Threaded
Open this post in threaded view
|

Re: Generate RandomString from a set of characters

Bruno P. Kinoshita-2
TIL :-)

Sent from Yahoo Mail on Android
 
  On Mon, 23 Oct 2017 at 20:39, Pascal Schumacher<[hidden email]> wrote:   Am 23.10.2017 um 05:29 schrieb Bruno P. Kinoshita:
> However, I don't think java faker provides random values based on regular expressions.
By the way java faker can provide random values based on regular
expressions:

new Faker().regexify(String regex)

It uses Generex to archive this.

Cheers,
Pascal