| 1 |
/foo|bar/ |
| 2 |
/h(e+)llo/ |
| 3 |
/\d+/ |
| 4 |
/あ/ |
| 5 |
|
| 6 |
/\// # slash |
| 7 |
/\\/ # backslash |
| 8 |
/\b/ # backspace |
| 9 |
/\e/ # escape |
| 10 |
/\f/ # form feed |
| 11 |
/\n/ # newline |
| 12 |
/\r/ # carriage return |
| 13 |
/\t/ # tab |
| 14 |
/\v/ # vertical tab |
| 15 |
/\NNN/ # octal ASCII character |
| 16 |
/\xNN/ # hexadecimal ASCII character |
| 17 |
/\x{FFFF}/ # hexadecimal unicode character |
| 18 |
/\x{10FFFF}/ # hexadecimal unicode character |
| 19 |
|
| 20 |
/foo/i.match("FOO") # => #<Regex::MatchData "FOO"> |
| 21 |
/foo/m.match("bar\nfoo") # => #<Regex::MatchData "foo"> |
| 22 |
/foo /x.match("foo") # => #<Regex::MatchData "foo"> |
| 23 |
/foo /imx.match("bar\nFOO") # => #<Regex::MatchData "FOO"> |
| 24 |
|
| 25 |
%r((/)) # => /(\/)/ |
| 26 |
%r[[/]] # => /[\/]/ |
| 27 |
%r{{/}} # => /{\/}/ |
| 28 |
%r<</>> # => /<\/>/ |
| 29 |
%r|/| # => /\// |
| 30 |
|
| 31 |
---------------------------------------------------- |
| 32 |
|
| 33 |
[ |
| 34 |
["regex-literal", [ |
| 35 |
["regex", "/foo|bar/"] |
| 36 |
]], |
| 37 |
["regex-literal", [ |
| 38 |
["regex", "/h(e+)llo/"] |
| 39 |
]], |
| 40 |
["regex-literal", [ |
| 41 |
["regex", "/\\d+/"] |
| 42 |
]], |
| 43 |
["regex-literal", [ |
| 44 |
["regex", "/あ/"] |
| 45 |
]], |
| 46 |
|
| 47 |
["regex-literal", [ |
| 48 |
["regex", "/\\//"] |
| 49 |
]], |
| 50 |
["comment", "# slash"], |
| 51 |
|
| 52 |
["regex-literal", [ |
| 53 |
["regex", "/\\\\/"] |
| 54 |
]], |
| 55 |
["comment", "# backslash"], |
| 56 |
|
| 57 |
["regex-literal", [ |
| 58 |
["regex", "/\\b/"] |
| 59 |
]], |
| 60 |
["comment", "# backspace"], |
| 61 |
|
| 62 |
["regex-literal", [ |
| 63 |
["regex", "/\\e/"] |
| 64 |
]], |
| 65 |
["comment", "# escape"], |
| 66 |
|
| 67 |
["regex-literal", [ |
| 68 |
["regex", "/\\f/"] |
| 69 |
]], |
| 70 |
["comment", "# form feed"], |
| 71 |
|
| 72 |
["regex-literal", [ |
| 73 |
["regex", "/\\n/"] |
| 74 |
]], |
| 75 |
["comment", "# newline"], |
| 76 |
|
| 77 |
["regex-literal", [ |
| 78 |
["regex", "/\\r/"] |
| 79 |
]], |
| 80 |
["comment", "# carriage return"], |
| 81 |
|
| 82 |
["regex-literal", [ |
| 83 |
["regex", "/\\t/"] |
| 84 |
]], |
| 85 |
["comment", "# tab"], |
| 86 |
|
| 87 |
["regex-literal", [ |
| 88 |
["regex", "/\\v/"] |
| 89 |
]], |
| 90 |
["comment", "# vertical tab"], |
| 91 |
|
| 92 |
["regex-literal", [ |
| 93 |
["regex", "/\\NNN/"] |
| 94 |
]], |
| 95 |
["comment", "# octal ASCII character"], |
| 96 |
|
| 97 |
["regex-literal", [ |
| 98 |
["regex", "/\\xNN/"] |
| 99 |
]], |
| 100 |
["comment", "# hexadecimal ASCII character"], |
| 101 |
|
| 102 |
["regex-literal", [ |
| 103 |
["regex", "/\\x{FFFF}/"] |
| 104 |
]], |
| 105 |
["comment", "# hexadecimal unicode character"], |
| 106 |
|
| 107 |
["regex-literal", [ |
| 108 |
["regex", "/\\x{10FFFF}/"] |
| 109 |
]], |
| 110 |
["comment", "# hexadecimal unicode character"], |
| 111 |
|
| 112 |
["regex-literal", [ |
| 113 |
["regex", "/foo/i"] |
| 114 |
]], |
| 115 |
["punctuation", "."], |
| 116 |
"match", |
| 117 |
["punctuation", "("], |
| 118 |
["string-literal", [ |
| 119 |
["string", "\"FOO\""] |
| 120 |
]], |
| 121 |
["punctuation", ")"], |
| 122 |
["comment", "# => #<Regex::MatchData \"FOO\">"], |
| 123 |
|
| 124 |
["regex-literal", [ |
| 125 |
["regex", "/foo/m"] |
| 126 |
]], |
| 127 |
["punctuation", "."], |
| 128 |
"match", |
| 129 |
["punctuation", "("], |
| 130 |
["string-literal", [ |
| 131 |
["string", "\"bar\\nfoo\""] |
| 132 |
]], |
| 133 |
["punctuation", ")"], |
| 134 |
["comment", "# => #<Regex::MatchData \"foo\">"], |
| 135 |
|
| 136 |
["regex-literal", [ |
| 137 |
["regex", "/foo /x"] |
| 138 |
]], |
| 139 |
["punctuation", "."], |
| 140 |
"match", |
| 141 |
["punctuation", "("], |
| 142 |
["string-literal", [ |
| 143 |
["string", "\"foo\""] |
| 144 |
]], |
| 145 |
["punctuation", ")"], |
| 146 |
["comment", "# => #<Regex::MatchData \"foo\">"], |
| 147 |
|
| 148 |
["regex-literal", [ |
| 149 |
["regex", "/foo /imx"] |
| 150 |
]], |
| 151 |
["punctuation", "."], |
| 152 |
"match", |
| 153 |
["punctuation", "("], |
| 154 |
["string-literal", [ |
| 155 |
["string", "\"bar\\nFOO\""] |
| 156 |
]], |
| 157 |
["punctuation", ")"], |
| 158 |
["comment", "# => #<Regex::MatchData \"FOO\">"], |
| 159 |
|
| 160 |
["regex-literal", [ |
| 161 |
["regex", "%r((/))"] |
| 162 |
]], |
| 163 |
["comment", "# => /(\\/)/"], |
| 164 |
|
| 165 |
["regex-literal", [ |
| 166 |
["regex", "%r[[/]]"] |
| 167 |
]], |
| 168 |
["comment", "# => /[\\/]/"], |
| 169 |
|
| 170 |
["regex-literal", [ |
| 171 |
["regex", "%r{{/}}"] |
| 172 |
]], |
| 173 |
["comment", "# => /{\\/}/"], |
| 174 |
|
| 175 |
["regex-literal", [ |
| 176 |
["regex", "%r<</>>"] |
| 177 |
]], |
| 178 |
["comment", "# => /<\\/>/"], |
| 179 |
|
| 180 |
["regex-literal", [ |
| 181 |
["regex", "%r|/|"] |
| 182 |
]], |
| 183 |
["comment", "# => /\\//"] |
| 184 |
] |