ProductPromotion
Logo

Elixir

made by https://0x3d.site

GitHub - caioceccon/random_string_generator: A Elixir module to generate a random string based on a given string pattern.
A Elixir module to generate a random string based on a given string pattern. - caioceccon/random_string_generator
Visit Site

GitHub - caioceccon/random_string_generator: A Elixir module to generate a random string based on a given string pattern.

GitHub - caioceccon/random_string_generator: A Elixir module to generate a random string based on a given string pattern.

RandomStringGenerator

Build Status codecov

A module to generate a random string based on a given string pattern

Installation

The package can be installed by adding random_string_generator to your list of dependencies in mix.exs:

def deps do
  [
    {:random_string_generator, "~> 1.0.0"}
  ]
end

Usage

Accepted string patterns:

Use l for lower case letter from a to z

Use L for upper case letter from A to Z

Use d for digit from 0 to 9

Use p for punctuation

Use c for custom character

Punctuation is any character on the following group:

!, ", #, $, %, &, ', (, ), *, +, ,, -, ., /, :, ;, <, =, >, ?, @, [, \, ], ^, _, {, |,}, ~ and `

Generate a string containing 2 lower case letters followed by 2 digits.
iex> RandomStringGenerator.generate("lldd")
"ol68"
Generate a string containing 2 upper case letters.
iex> RandomStringGenerator.generate("LL")
"VR"
Generate a string containing 2 punctuations.
iex> RandomStringGenerator.generate("pp")
"?!"

Delimiters

Everything that is not l,L,d,p and c is treated as a delimiter so the pattern -dl? is interpreted as a hyphen followed by a digit followed by a lower case letter followed by a question mark.

Generate a string containing 2 letters followed by a hyphen.
iex> RandomStringGenerator.generate("ll-")
"yz-"

Scape

In order to generate a string containing the characters l,L,d and p as a delimiter, you need to use the backslash twice in order to scape it.

Generate a string containing 2 digits followed by the letters lLdp.
iex> RandomStringGenerator.generate("dd\\l\\L\\d\\p")
"39lLdp"

Custom Chars

I order to generate a string based on a given custom pattern ccc a list of possible values need to be passed as an argument.

Generate a string containing 3 custom chars from the list ["+", "-", "/", "*"].
iex> RandomStringGenerator.generate("ccc", ["+", "-", "/", "*"])
"+/*"

If no custom char list is passed the with character c it will be treated as a delimiter as in the example below where it generates a string containing one digit followed by the letter c followed by another digit

iex> RandomStringGenerator.generate("dcd")
"2c1"

Shuffling

In order to generate a string based on a given patter Lldd where those characters are placed in a random order, the shuffle/1 function should be used.

Generate a string containing 2 lower case letters, 2 digits in random order.
iex> RandomStringGenerator.generate("Lldd") |> RandomStringGenerator.shuffle()
"s22E"

Full documentation at https://hexdocs.pm/random_string_generator.

Articles
to learn more about the elixir concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here 🔥.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here 🔥.

Queries
or most google FAQ's about Elixir.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory