benburkert/randexp

Can't generate a literal plus '+' character

Opened this issue · 5 comments

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
 => "+"

+1 to address this as well.

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

+1

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.