By far, the best tool for the job is RegExr.
The link above will take you to the online version, which is awesome and definitely the best RegEx tool I've ever used.
If you're looking for something you can install in Ubuntu, then try the desktop version, which is an Adobe Air application:

Regex generator
Random data generator matching a regex in python - Stack Overflow
How to create a regex pattern
Does a regular expression generator exist?
Videos
By far, the best tool for the job is RegExr.
The link above will take you to the online version, which is awesome and definitely the best RegEx tool I've ever used.
If you're looking for something you can install in Ubuntu, then try the desktop version, which is an Adobe Air application:

Kodos is an application to aid in the creation and debugging of regular expressions in python. The GUI for Kodos should eliminate the need for using the python interpreter for regex design in most instances.
Homepage: http://kodos.sourceforge.net/
Or online tool: http://www.regextester.com/
Hi !
Is there such a thing as regex generator?
Im not sure if regex101 or regexr do that.
Maybe you can suggest any IDE plugins for regex? What do you use for your regex tasks ?
Thanks!
Two Python libraries can do this: sre-yield and Hypothesis.
- sre-yield
sre-yeld will generate all values matching a given regular expression. It uses SRE, Python's default regular expression engine.
For example,
import sre_yield
list(sre_yield.AllStrings('[a-z]oo$'))
['aoo', 'boo', 'coo', 'doo', 'eoo', 'foo', 'goo', 'hoo', 'ioo', 'joo', 'koo', 'loo', 'moo', 'noo', 'ooo', 'poo', 'qoo', 'roo', 'soo', 'too', 'uoo', 'voo', 'woo', 'xoo', 'yoo', 'zoo']
For decimal numbers,
list(sre_yield.AllStrings('\d{1,2}'))
['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59', '60', '61', '62', '63', '64', '65', '66', '67', '68', '69', '70', '71', '72', '73', '74', '75', '76', '77', '78', '79', '80', '81', '82', '83', '84', '85', '86', '87', '88', '89', '90', '91', '92', '93', '94', '95', '96', '97', '98', '99']
- Hypothesis
The unit test library Hypothesis will generate random matching examples. It is also built using SRE.
import hypothesis
g=hypothesis.strategies.from_regex(r'^[A-Z][a-z]$')
g.example()
with output such as:
'Gssov', 'Lmsud', 'Ixnoy'
For decimal numbers
d=hypothesis.strategies.from_regex(r'^[0-9]{1,2}$')
will output one or two digit decimal numbers: 65, 7, 67 although not evenly distributed. Using \d yielded unprintable strings.
Note: use begin and end anchors to prevent extraneous characters.
If the expressions you match do not have any "advanced" features, like look-ahead or look-behind, then you can parse it yourself and build a proper generator
Treat each part of the regex as a function returning something (e.g., between 1 and 100 digits) and glue them together at the top:
import random
from string import digits, uppercase, letters
def joiner(*items):
# actually should return lambda as the other functions
return ''.join(item() for item in items)
def roll(item, n1, n2=None):
n2 = n2 or n1
return lambda: ''.join(item() for _ in xrange(random.randint(n1, n2)))
def rand(collection):
return lambda: random.choice(collection)
# this is a generator for /\d{1,10}:[A-Z]{5}/
print joiner(roll(rand(digits), 1, 10),
rand(':'),
roll(rand(uppercase), 5))
# [A-C]{2}\d{2,20}@\w{10,1000}
print joiner(roll(rand('ABC'), 2),
roll(rand(digits), 2, 20),
rand('@'),
roll(rand(letters), 10, 1000))
Parsing the regex would be another question. So this solution is not universal, but maybe it's sufficient
For example, given a list of characters*, is there a tool to generate a regular expression that matches items in the list?
Looking to use something like that to define the 'pattern' property in json draft 4 specs. Python style regex is fine.
(*) edited to be more general.
Sample data:
['XCP', 'STEEM', 'BTM', 'PINK', 'NXT', 'BTS', 'ETH', 'MAID', 'SYS', 'BCY', 'PASC', 'XEM', 'NAV', 'DCR', 'BTC', 'BLK', 'POT', 'ARDR', 'VRC', 'XRP', 'RIC', 'AMP', 'REP', 'XVC', 'DGB', 'GAME', 'PPC', 'LBC', 'GNT', 'GNO', 'XBC', 'FLO', 'OMG', 'NXC', 'BCH', 'DASH', 'EMC2', 'GRC', 'ETC', 'XPM', 'LSK', 'BURST', 'EXP', 'RADS', 'FLDC', 'DOGE', 'CVC', 'LTC', 'BCN', 'SBD', 'GAS', 'CLAM', 'HUC', 'FCT', 'VTC', 'XMR', 'VIA', 'STRAT', 'NEOS', 'SC', 'ZEC', 'BTCD', 'NMC', 'OMNI', 'STR', 'STORJ', 'ZRX']
I wouldn't expect the tool to be perfect due to the number of possibilities. I'm just looking for something that will help me identify the patterns quickly and possibly spot outliers. This would not be used in place of proper validation. Would also be interested in comparing the output of a regex generator to my patterns or something that refactors existing regular expressions in simplest terms - for learning purposes.
[A-Z]{2,6} 100%
[A-Z]{3,6} 98%