|
50 | 50 | output << h(params[:replacement]) |
51 | 51 | output << "</td>\n" |
52 | 52 |
|
| 53 | + options = 0 |
| 54 | + str_options = request_params_multi(request.query_string)["option"] |
| 55 | + if str_options |
| 56 | + if str_options.include?("comment") |
| 57 | + options += Regexp::EXTENDED |
| 58 | + end |
| 59 | + if str_options.include?("dotall") |
| 60 | + options += Regexp::MULTILINE |
| 61 | + end |
| 62 | + if str_options.include?("ignorecase") |
| 63 | + options += Regexp::IGNORECASE |
| 64 | + end |
| 65 | + end |
| 66 | + |
| 67 | + regex = Regexp.new(str_regex, options) |
53 | 68 | # when ruby 1.9 |
54 | 69 | #if Regexp.try_convert(str_regex) |
55 | 70 | # output << "\t<tr>\n" |
|
64 | 79 | # } ) |
65 | 80 | #end |
66 | 81 |
|
67 | | - regex = Regexp.new(str_regex) |
| 82 | + if regex |
| 83 | + output << "\t<tr>\n" |
| 84 | + output << "\t\t<td>Options</td>\n" |
| 85 | + output << "\t\t<td>" |
| 86 | + output << regex.options.to_s |
| 87 | + output << "</td>\n" |
| 88 | + output << "\t</tr>\n" |
68 | 89 |
|
69 | | - output << "\t</tr>\n" |
| 90 | + if regex.options != 0 |
| 91 | + output << "\t<tr>\n" |
| 92 | + output << "\t\t<td>Options as constants</td>\n" |
| 93 | + output << "\t\t<td>" |
| 94 | + if (regex.options & Regexp::IGNORECASE) != 0 |
| 95 | + output << "Regexp::IGNORECASE " |
| 96 | + end |
| 97 | + if (regex.options & Regexp::EXTENDED) != 0 |
| 98 | + output << "Regexp::EXTENDED " |
| 99 | + end |
| 100 | + if (regex.options & Regexp::MULTILINE) != 0 |
| 101 | + output << "Regexp::MULTILINE " |
| 102 | + end |
| 103 | + #if (regex.options & Regexp::FIXEDENCODING) != 0 |
| 104 | + # output << "Regexp::FIXEDENCODING " |
| 105 | + #end |
| 106 | + #if (regex.options & Regexp::NOENCODING) != 0 |
| 107 | + # output << "Regexp::NOENCODING " |
| 108 | + #end |
| 109 | + output << "</td>\n" |
| 110 | + output << "\t</tr>\n" |
| 111 | + end |
| 112 | + |
| 113 | + #names = regex.names |
| 114 | + #if names |
| 115 | + # output << "\t<tr>\n" |
| 116 | + # output << "\t\t<td>Named captures (names)</td>\n" |
| 117 | + # output << "\t\t<td>" |
| 118 | + # output << h(names.to_s) |
| 119 | + # output << "</td>\n" |
| 120 | + #end |
| 121 | + |
| 122 | + end |
70 | 123 |
|
71 | 124 | output << "</table>\n" |
72 | 125 |
|
|
75 | 128 | output << "\t<tr>\n" |
76 | 129 | output << "\t\t<th style=\"text-align:center;\">Test</th>\n" |
77 | 130 | output << "\t\t<th>Input</th>" |
| 131 | + output << "\t\t<th>=~</th>" |
78 | 132 | output << "\t\t<th>match()</th>" |
79 | 133 | output << "\t</tr>\n" |
80 | 134 |
|
|
104 | 158 | output << "\t\t<td>" |
105 | 159 | output << h(input) |
106 | 160 | output << "</td>\n" |
| 161 | + |
| 162 | + output << "\t\t<td>" |
| 163 | + eq = regex =~ input |
| 164 | + if eq: |
| 165 | + output << h(eq.to_s) |
| 166 | + else |
| 167 | + output << "<i>nil</i>" |
| 168 | + end |
| 169 | + output << "</td>\n" |
| 170 | + |
107 | 171 | md = regex.match(input) |
108 | 172 | if md == nil |
109 | 173 | output << "\t\t<td><i>" |
|
117 | 181 | first = false |
118 | 182 | else |
119 | 183 | output << "\t<tr>\n" |
120 | | - output << "\t\t<td colspan=\"2\" style=\"text-align:right;\">regex.match(matchdata.post_match)</td>" |
| 184 | + output << "\t\t<td colspan=\"3\" style=\"text-align:right;\">regex.match(matchdata.post_match)</td>" |
121 | 185 | end |
122 | 186 | output << "\t\t<td>" |
123 | | - output << h(md.inspect) |
| 187 | + for mdindex in 0..md.size-1 |
| 188 | + output << "[" |
| 189 | + output << mdindex.to_s |
| 190 | + output << "]: " |
| 191 | + output << h(md[mdindex]) |
| 192 | + output << "<br/>" |
| 193 | + end |
124 | 194 | output << "</td>\n" |
125 | 195 | output << "\t</tr>\n" |
126 | 196 | md = regex.match(md.post_match) |
|
0 commit comments