re = /^..(.[!G)(3w^]|.{7}$|$)|\$\?/m
str = 'The next answer has to match the following strings:
PPCG
^P
^[P^]P
[^?][PG]$
(?<!\\\\..)(?!]).$
^[\\w^]*$|!|]P|G]\\$$
!|[^?]P(CG|G..)?$
[^])]\\$|^\\^?P|P.\\].$
([.$?]|G\\])\\$$|^\\^?P|\\]P$
([P.$?]\\$|[]^]P|G\\]\\$|CG)$
!|((G.|P|\\.)\\$|[^?]P|CG)$
^[(!P]|G..$|]..\\||[^?]P$
^.{3,23}[.-~]..\\$$|[^P?][PG]$
And fail on these strings:
[PPCG]
^[P\\^]
[^\\]]$
^\\^?P
[^?][PG]$|<|PG
^[^\\\\|]*(\\\\\\\\)+[^\\\\|]*[^\\]]$
^(.{,4}|.{9}|.{16,19}|.{5}P)$
^[^?]*[PG]$|[?$].*\\$$
^[^[]P|]P|(G]|[.])\\$$
\\..$|!|\\|G|^[\\^P]P|P\\^|G.\\$$
...\\^.P|^!|G]\\$$|w|<!|^\\^?P
([^\\\\}<]{3}|][^]]|^).?[$PG]$
^(..[^^].{4,22}\\$|[^?]+\\w)$|2
^(..[^^].{4,22}\\$|[^?]+\\w)$|~'
# Print the match result
str.scan(re) do |match|
puts match.to_s
end
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html