re.gsub(/^\/?\^?/,"").gsub(/\$?\/?$/,"")# Ditch the anchors
.gsub(/\{(\d+)\}/){"{#{$1},#{$1}}"}.gsub(/\?/,"{0,1}")# All {2} become {2,2} and ? become {0,1}
.gsub(/(\[[^\]]+\])\{(\d+),(\d+)\}/){|match|$1*(Range.new($2.to_i,$3.to_i)).to_a.sample(@@rng)}# [12]{1,2} becomes [12] or [12][12]
.gsub(/(\([^\)]+\))\{(\d+),(\d+)\}/){|match|$1*($2.to_i..$3.to_i).to_a.sample(@@rng)}# (12|34){1,2} becomes (12|34) or (12|34)(12|34)
.gsub(/(\\?.)\{(\d+),(\d+)\}/){|match|$1*($2.to_i..$3.to_i).to_a.sample(@@rng)}# A{1,2} becomes A or AA or \d{3} becomes \d\d\d
.gsub(/\((.*?)\)/){|match|match.gsub(/[\(\)]/,"").split("|").sample(@@rng)}# (this|that) becomes "this" or "that"
.gsub(/\[([^\]]+)\]/){|match|match.gsub(/(\w\-\w)/){|range|((0...range.size).map{|i|range[i].to_s}).join("").split("-").to_a.sample(@@rng)}}# All A-Z inside of [] become C (or X, or whatever)
.gsub(/\[([^\]]+)\]/){|match|$1.split("").sample(@@rng)}# All [ABC] become B (or A or C)