Hi All,

I'd apritiate if someone can provide valuable inputs / suggestions /
improvements.

I think this will be value added to RandomStringGenerator.

Regards,
Amey

On Tue, Jun 27, 2017, 11:40 PM Amey Jadiye <ameyjad...@gmail.com> wrote:

> Hi All,
>
> With below reference user asked whether he can use alpha numeric string ?
>  we can do that easily by overloading .withinRange(char[][])
> where my vision is to pass multiple pairs of min max characters. so we can
> pas {'0','9'} and {'a','z'}, OR any similar alternative where we can pass
> pairs of range.
>
> i.e.
>
> RandomStringGenerator generator = new
>                 RandomStringGenerator.Builder()
>                 .withinRange({'0','9'}, {'a','z'}).build();
>
>
> What do you guys think  ?
>
> Regards,
> Amey
>
> ---------- Forwarded message ----------
> From: Amey Jadiye <ameyjad...@gmail.com>
> Date: Tue, Jun 27, 2017 at 10:57 PM
> Subject: Re: [text] - using RandomStringGenerator for alpha numeric
> To: Commons Users List <u...@commons.apache.org>, gregh3...@gmail.com
>
>
> Hi Greg,
>
> Thanks for writing to us, as range are the codePoints you can use it like
> below.
>
> RandomStringGenerator generator = new
>                 RandomStringGenerator.Builder()
>                 .withinRange('0', 'z').build();
>
> However that will include all the numbers, capital letters, small letters
> and some special characters. between (48 to 112)
>
> We are including feature in next release so you can give characters you
> want to generate random string, but that will be available in Text 1.2
> release.
>
> For now as an alternate you can use below code as well passing it array of
> a to z and 0 to 9.
>
> Set<Integer> characters = Stream.of('a', 'b', '1', '2').map(i -> (int)
> i).collect(Collectors.toSet());
> String str = new RandomStringGenerator.Builder().filteredBy(i ->
> characters.contains(i)).build().generate(5);
>
> Let us know if you need more info.
>
> Regards,
> Amey
>
> On Tue, Jun 27, 2017 at 8:03 PM, Greg Huber <gregh3...@gmail.com> wrote:
>
>> ​Hello,
>>
>> How would I use org.apache.commons.text.RandomStringGenerator to replace
>> the RandomStringUtils alpha numeric number?
>>
>> String text = RandomStringUtils.randomAlphanumeric(num);
>>
>> The docs only show how to use a-z :
>>
>> RandomStringGenerator generator = new
>>                 RandomStringGenerator.Builder()
>>                 .withinRange('a', 'z').build();
>>
>> String text = generator.generate(num);
>>
>> Cheers
>>
>> ​
>>
>
>
>
> --
>
> ---------------------------------------------------------------------
>
> To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
>
> For additional commands, e-mail: dev-h...@commons.apache.org
>
>
>
> --
>
> ---------------------------------------------------------------------
>
> To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
>
> For additional commands, e-mail: dev-h...@commons.apache.org
>

Reply via email to