benburkert / randexp

generate random data from a Regular Expression
MIT License
286 stars 43 forks source link

Can't generate a literal plus '+' character #12

Open cimbriano opened 11 years ago

cimbriano commented 11 years ago

Both of the following raise RuntimeError but are valid (shown below)

/\+/.gen
/[+]/.gen

RuntimeError: Sorry, "+" is too vague, try setting a range: "{1,3}" RuntimeError: Sorry, "[+" is too vague, try setting a range: "[{1,3}"

:015 > "+".match(/\+/).string
 => "+"
:016 > "+".match(/[+]/).string
 => "+"
avelis commented 10 years ago

+1 to address this as well.

mockaroo commented 10 years ago

+1 In general is there a way to generate literal reserved characters such as "?" and "|"?

bhagyas commented 10 years ago

+1

konstantin-dzreev commented 10 years ago

+1

tom-lord commented 9 years ago

For more "accurate" generation of regex examples, check out my gem: https://github.com/tom-lord/regexp-examples

This gem seems better suited to generating one random example of a long pattern, e.g. /\w{10}/.gen, but mine can correctly parse (almost) the WHOLE regex language.