/foo|bar/ /h(e+)llo/ /\d+/ /あ/ /\// # slash /\\/ # backslash /\b/ # backspace /\e/ # escape /\f/ # form feed /\n/ # newline /\r/ # carriage return /\t/ # tab /\v/ # vertical tab /\NNN/ # octal ASCII character /\xNN/ # hexadecimal ASCII character /\x{FFFF}/ # hexadecimal unicode character /\x{10FFFF}/ # hexadecimal unicode character /foo/i.match("FOO") # => # /foo/m.match("bar\nfoo") # => # /foo /x.match("foo") # => # /foo /imx.match("bar\nFOO") # => # %r((/)) # => /(\/)/ %r[[/]] # => /[\/]/ %r{{/}} # => /{\/}/ %r<> # => /<\/>/ %r|/| # => /\// ---------------------------------------------------- [ ["regex-literal", [ ["regex", "/foo|bar/"] ]], ["regex-literal", [ ["regex", "/h(e+)llo/"] ]], ["regex-literal", [ ["regex", "/\\d+/"] ]], ["regex-literal", [ ["regex", "/あ/"] ]], ["regex-literal", [ ["regex", "/\\//"] ]], ["comment", "# slash"], ["regex-literal", [ ["regex", "/\\\\/"] ]], ["comment", "# backslash"], ["regex-literal", [ ["regex", "/\\b/"] ]], ["comment", "# backspace"], ["regex-literal", [ ["regex", "/\\e/"] ]], ["comment", "# escape"], ["regex-literal", [ ["regex", "/\\f/"] ]], ["comment", "# form feed"], ["regex-literal", [ ["regex", "/\\n/"] ]], ["comment", "# newline"], ["regex-literal", [ ["regex", "/\\r/"] ]], ["comment", "# carriage return"], ["regex-literal", [ ["regex", "/\\t/"] ]], ["comment", "# tab"], ["regex-literal", [ ["regex", "/\\v/"] ]], ["comment", "# vertical tab"], ["regex-literal", [ ["regex", "/\\NNN/"] ]], ["comment", "# octal ASCII character"], ["regex-literal", [ ["regex", "/\\xNN/"] ]], ["comment", "# hexadecimal ASCII character"], ["regex-literal", [ ["regex", "/\\x{FFFF}/"] ]], ["comment", "# hexadecimal unicode character"], ["regex-literal", [ ["regex", "/\\x{10FFFF}/"] ]], ["comment", "# hexadecimal unicode character"], ["regex-literal", [ ["regex", "/foo/i"] ]], ["punctuation", "."], "match", ["punctuation", "("], ["string-literal", [ ["string", "\"FOO\""] ]], ["punctuation", ")"], ["comment", "# => #"], ["regex-literal", [ ["regex", "/foo/m"] ]], ["punctuation", "."], "match", ["punctuation", "("], ["string-literal", [ ["string", "\"bar\\nfoo\""] ]], ["punctuation", ")"], ["comment", "# => #"], ["regex-literal", [ ["regex", "/foo /x"] ]], ["punctuation", "."], "match", ["punctuation", "("], ["string-literal", [ ["string", "\"foo\""] ]], ["punctuation", ")"], ["comment", "# => #"], ["regex-literal", [ ["regex", "/foo /imx"] ]], ["punctuation", "."], "match", ["punctuation", "("], ["string-literal", [ ["string", "\"bar\\nFOO\""] ]], ["punctuation", ")"], ["comment", "# => #"], ["regex-literal", [ ["regex", "%r((/))"] ]], ["comment", "# => /(\\/)/"], ["regex-literal", [ ["regex", "%r[[/]]"] ]], ["comment", "# => /[\\/]/"], ["regex-literal", [ ["regex", "%r{{/}}"] ]], ["comment", "# => /{\\/}/"], ["regex-literal", [ ["regex", "%r<>"] ]], ["comment", "# => /<\\/>/"], ["regex-literal", [ ["regex", "%r|/|"] ]], ["comment", "# => /\\//"] ]