Regular Expressions
While Mockaroo supports a ton of built-in datatypes, it doesn't have everything and probably never will. Fortunately, you can use the powerful Regular Expression datatype to generate random data in almost any format.
The following character classes are supported:
\d | numbers |
\w | words from lorem ipsum |
[:alpha:] | letters |
[:upper:] | uppercase letters |
[:lower:] | lowercase letters |
[:name:] | random first and last name |
[:first_name:] | random first name |
[:last_name:] | random last name |
[:plus:] | + |
[:question:] | ? |
{{ my_field }} | Value of field named "my field" |
Examples
Aa3h15!
=> "Aaaahhhhh!"\d4
=> "5168"[:upper:]2-\d3-[:lower:]1
=> "XS-455-c"((A|B|C)2)((1|2|3)3)
=> "CB211"[:plus:]\d2 \d3 \d3 \d4
=> "+01 410 555 3934"Mockaroo uses randgen for generating values from regular expressions. See the randgen documentation for more info on syntax.
Use Case: Currencies
Let's say you want to generate random prices between 1 and 100 in different currencies that look like:
10,26 AUD
3,99 EUR
100,00 CNY
...
You can generate data like this by first creating a Currency Code field called "currency", then a Regular Expression field called "price" with the following pattern:
\d{1,3},\d{2} {{currency}}
By combining Mockaroo's built-in datatypes with your own regular expressions, you can mock virtually any type of data!