| | | 1 | | // <auto-generated/> |
| | | 2 | | #nullable enable |
| | | 3 | | #pragma warning disable |
| | | 4 | | |
| | | 5 | | namespace ArturRios.Util.RegularExpressions |
| | | 6 | | { |
| | | 7 | | partial class RegexCollection |
| | | 8 | | { |
| | | 9 | | /// <remarks> |
| | | 10 | | /// Pattern:<br/> |
| | | 11 | | /// <code>^[\\w!#$%&'*+\\-/=?\\^_`{|}~]+(\\.[\\w!#$%&'*+\\-/=?\\^_`{|}~]+)*@((([\\-\\w]+\\.)+[a-zA-Z]{2, |
| | | 12 | | /// Explanation:<br/> |
| | | 13 | | /// <code> |
| | | 14 | | /// ○ Match if at the beginning of the string.<br/> |
| | | 15 | | /// ○ Match a character in the set [!#-'*+\-/=?^-`{-~\w] greedily at least once.<br/> |
| | | 16 | | /// ○ Loop greedily any number of times.<br/> |
| | | 17 | | /// ○ 1st capture group.<br/> |
| | | 18 | | /// ○ Match '.'.<br/> |
| | | 19 | | /// ○ Match a character in the set [!#-'*+\-/=?^-`{-~\w] atomically at least once.<br/> |
| | | 20 | | /// ○ Match '@'.<br/> |
| | | 21 | | /// ○ 2nd capture group.<br/> |
| | | 22 | | /// ○ Match with 2 alternative expressions.<br/> |
| | | 23 | | /// ○ 3rd capture group.<br/> |
| | | 24 | | /// ○ Loop greedily at least once.<br/> |
| | | 25 | | /// ○ 4th capture group.<br/> |
| | | 26 | | /// ○ Match a character in the set [\-\w] atomically at least once.<br/> |
| | | 27 | | /// ○ Match '.'.<br/> |
| | | 28 | | /// ○ Match an ASCII letter atomically at least 2 and at most 4 times.<br/> |
| | | 29 | | /// ○ 5th capture group.<br/> |
| | | 30 | | /// ○ Loop exactly 3 times.<br/> |
| | | 31 | | /// ○ 6th capture group.<br/> |
| | | 32 | | /// ○ Match a character in the set [0-9] atomically at least 1 and at most 3 times.<br/> |
| | | 33 | | /// ○ Match '.'.<br/> |
| | | 34 | | /// ○ Match a character in the set [0-9] atomically at least 1 and at most 3 times.<br/> |
| | | 35 | | /// ○ Match if at the end of the string or if before an ending newline.<br/> |
| | | 36 | | /// </code> |
| | | 37 | | /// </remarks> |
| | | 38 | | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "10.0.13.700 |
| | | 39 | | public static partial global::System.Text.RegularExpressions.Regex Email() => global::System.Text.RegularExpress |
| | | 40 | | } |
| | | 41 | | } |
| | | 42 | | |
| | | 43 | | namespace ArturRios.Util.RegularExpressions |
| | | 44 | | { |
| | | 45 | | partial class RegexCollection |
| | | 46 | | { |
| | | 47 | | /// <remarks> |
| | | 48 | | /// Pattern:<br/> |
| | | 49 | | /// <code>[0-9]+</code><br/> |
| | | 50 | | /// Explanation:<br/> |
| | | 51 | | /// <code> |
| | | 52 | | /// ○ Match a character in the set [0-9] atomically at least once.<br/> |
| | | 53 | | /// </code> |
| | | 54 | | /// </remarks> |
| | | 55 | | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "10.0.13.700 |
| | | 56 | | public static partial global::System.Text.RegularExpressions.Regex HasNumber() => global::System.Text.RegularExp |
| | | 57 | | } |
| | | 58 | | } |
| | | 59 | | |
| | | 60 | | namespace ArturRios.Util.RegularExpressions |
| | | 61 | | { |
| | | 62 | | partial class RegexCollection |
| | | 63 | | { |
| | | 64 | | /// <remarks> |
| | | 65 | | /// Pattern:<br/> |
| | | 66 | | /// <code>[a-z]+</code><br/> |
| | | 67 | | /// Explanation:<br/> |
| | | 68 | | /// <code> |
| | | 69 | | /// ○ Match a character in the set [a-z] atomically at least once.<br/> |
| | | 70 | | /// </code> |
| | | 71 | | /// </remarks> |
| | | 72 | | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "10.0.13.700 |
| | | 73 | | public static partial global::System.Text.RegularExpressions.Regex HasLowerChar() => global::System.Text.Regular |
| | | 74 | | } |
| | | 75 | | } |
| | | 76 | | |
| | | 77 | | namespace ArturRios.Util.RegularExpressions |
| | | 78 | | { |
| | | 79 | | partial class RegexCollection |
| | | 80 | | { |
| | | 81 | | /// <remarks> |
| | | 82 | | /// Pattern:<br/> |
| | | 83 | | /// <code>[A-Z]+</code><br/> |
| | | 84 | | /// Explanation:<br/> |
| | | 85 | | /// <code> |
| | | 86 | | /// ○ Match a character in the set [A-Z] atomically at least once.<br/> |
| | | 87 | | /// </code> |
| | | 88 | | /// </remarks> |
| | | 89 | | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "10.0.13.700 |
| | | 90 | | public static partial global::System.Text.RegularExpressions.Regex HasUpperChar() => global::System.Text.Regular |
| | | 91 | | } |
| | | 92 | | } |
| | | 93 | | |
| | | 94 | | namespace ArturRios.Util.RegularExpressions |
| | | 95 | | { |
| | | 96 | | partial class RegexCollection |
| | | 97 | | { |
| | | 98 | | /// <remarks> |
| | | 99 | | /// Pattern:<br/> |
| | | 100 | | /// <code>^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d).+$</code><br/> |
| | | 101 | | /// Explanation:<br/> |
| | | 102 | | /// <code> |
| | | 103 | | /// ○ Match if at the beginning of the string.<br/> |
| | | 104 | | /// ○ Zero-width positive lookahead.<br/> |
| | | 105 | | /// ○ Match a character other than '\n' greedily any number of times.<br/> |
| | | 106 | | /// ○ Match a character in the set [a-z].<br/> |
| | | 107 | | /// ○ Zero-width positive lookahead.<br/> |
| | | 108 | | /// ○ Match a character other than '\n' greedily any number of times.<br/> |
| | | 109 | | /// ○ Match a character in the set [A-Z].<br/> |
| | | 110 | | /// ○ Zero-width positive lookahead.<br/> |
| | | 111 | | /// ○ Match a character other than '\n' greedily any number of times.<br/> |
| | | 112 | | /// ○ Match a Unicode digit.<br/> |
| | | 113 | | /// ○ Match a character other than '\n' greedily at least once.<br/> |
| | | 114 | | /// ○ Match if at the end of the string or if before an ending newline.<br/> |
| | | 115 | | /// </code> |
| | | 116 | | /// </remarks> |
| | | 117 | | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "10.0.13.700 |
| | | 118 | | public static partial global::System.Text.RegularExpressions.Regex HasNumberLowerAndUpperChar() => global::Syste |
| | | 119 | | } |
| | | 120 | | } |
| | | 121 | | |
| | | 122 | | namespace System.Text.RegularExpressions.Generated |
| | | 123 | | { |
| | | 124 | | using System; |
| | | 125 | | using System.Buffers; |
| | | 126 | | using System.CodeDom.Compiler; |
| | | 127 | | using System.Collections; |
| | | 128 | | using System.ComponentModel; |
| | | 129 | | using System.Globalization; |
| | | 130 | | using System.Runtime.CompilerServices; |
| | | 131 | | using System.Text.RegularExpressions; |
| | | 132 | | using System.Threading; |
| | | 133 | | |
| | | 134 | | /// <summary>Custom <see cref="Regex"/>-derived type for the Email method.</summary> |
| | | 135 | | [GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "10.0.13.7005")] |
| | | 136 | | file sealed class Email_0 : Regex |
| | | 137 | | { |
| | | 138 | | /// <summary>Cached, thread-safe singleton instance.</summary> |
| | | 139 | | internal static readonly Email_0 Instance = new(); |
| | | 140 | | |
| | | 141 | | /// <summary>Initializes the instance.</summary> |
| | | 142 | | private Email_0() |
| | | 143 | | { |
| | | 144 | | base.pattern = "^[\\w!#$%&'*+\\-/=?\\^_`{|}~]+(\\.[\\w!#$%&'*+\\-/=?\\^_`{|}~]+)*@((([\\-\\w]+\\.)+[a-zA-Z]{ |
| | | 145 | | base.roptions = RegexOptions.None; |
| | | 146 | | ValidateMatchTimeout(Utilities.s_defaultTimeout); |
| | | 147 | | base.internalMatchTimeout = Utilities.s_defaultTimeout; |
| | | 148 | | base.factory = new RunnerFactory(); |
| | | 149 | | base.capsize = 7; |
| | | 150 | | } |
| | | 151 | | |
| | | 152 | | /// <summary>Provides a factory for creating <see cref="RegexRunner"/> instances to be used by methods on <see c |
| | | 153 | | private sealed class RunnerFactory : RegexRunnerFactory |
| | | 154 | | { |
| | | 155 | | /// <summary>Creates an instance of a <see cref="RegexRunner"/> used by methods on <see cref="Regex"/>.</sum |
| | | 156 | | protected override RegexRunner CreateInstance() => new Runner(); |
| | | 157 | | |
| | | 158 | | /// <summary>Provides the runner that contains the custom logic implementing the specified regular expressio |
| | | 159 | | private sealed class Runner : RegexRunner |
| | | 160 | | { |
| | | 161 | | /// <summary>Scan the <paramref name="inputSpan"/> starting from base.runtextstart for the next match.</ |
| | | 162 | | /// <param name="inputSpan">The text being scanned by the regular expression.</param> |
| | | 163 | | protected override void Scan(ReadOnlySpan<char> inputSpan) |
| | | 164 | | { |
| | | 165 | | // The pattern is anchored. Validate the current position and try to match at it only. |
| | | 166 | | if (TryFindNextPossibleStartingPosition(inputSpan) && !TryMatchAtCurrentPosition(inputSpan)) |
| | | 167 | | { |
| | | 168 | | base.runtextpos = inputSpan.Length; |
| | | 169 | | } |
| | | 170 | | } |
| | | 171 | | |
| | | 172 | | /// <summary>Search <paramref name="inputSpan"/> starting from base.runtextpos for the next location a m |
| | | 173 | | /// <param name="inputSpan">The text being scanned by the regular expression.</param> |
| | | 174 | | /// <returns>true if a possible match was found; false if no more matches are possible.</returns> |
| | | 175 | | private bool TryFindNextPossibleStartingPosition(ReadOnlySpan<char> inputSpan) |
| | | 176 | | { |
| | | 177 | | int pos = base.runtextpos; |
| | | 178 | | |
| | | 179 | | // Any possible match is at least 6 characters. |
| | | 180 | | if (pos <= inputSpan.Length - 6) |
| | | 181 | | { |
| | | 182 | | // The pattern leads with a beginning (\A) anchor. |
| | | 183 | | if (pos == 0) |
| | | 184 | | { |
| | | 185 | | return true; |
| | | 186 | | } |
| | | 187 | | } |
| | | 188 | | |
| | | 189 | | // No match found. |
| | | 190 | | base.runtextpos = inputSpan.Length; |
| | | 191 | | return false; |
| | | 192 | | } |
| | | 193 | | |
| | | 194 | | /// <summary>Determine whether <paramref name="inputSpan"/> at base.runtextpos is a match for the regula |
| | | 195 | | /// <param name="inputSpan">The text being scanned by the regular expression.</param> |
| | | 196 | | /// <returns>true if the regular expression matches at the current position; otherwise, false.</returns> |
| | | 197 | | private bool TryMatchAtCurrentPosition(ReadOnlySpan<char> inputSpan) |
| | | 198 | | { |
| | | 199 | | int pos = base.runtextpos; |
| | | 200 | | int matchStart = pos; |
| | | 201 | | char ch; |
| | | 202 | | int alternation_branch = 0; |
| | | 203 | | int alternation_starting_capturepos = 0; |
| | | 204 | | int alternation_starting_pos = 0; |
| | | 205 | | int capture_starting_pos1 = 0; |
| | | 206 | | int capture_starting_pos2 = 0; |
| | | 207 | | int capture_starting_pos4 = 0; |
| | | 208 | | int charloop_capture_pos = 0; |
| | | 209 | | int charloop_starting_pos = 0, charloop_ending_pos = 0; |
| | | 210 | | int loop_iteration = 0; |
| | | 211 | | int loop_iteration1 = 0; |
| | | 212 | | int stackpos = 0; |
| | | 213 | | ReadOnlySpan<char> slice = inputSpan.Slice(pos); |
| | | 214 | | |
| | | 215 | | // Match if at the beginning of the string. |
| | | 216 | | if (pos != 0) |
| | | 217 | | { |
| | | 218 | | UncaptureUntil(0); |
| | | 219 | | return false; // The input didn't match. |
| | | 220 | | } |
| | | 221 | | |
| | | 222 | | // Match a character in the set [!#-'*+\-/=?^-`{-~\w] greedily at least once. |
| | | 223 | | //{ |
| | | 224 | | charloop_starting_pos = pos; |
| | | 225 | | |
| | | 226 | | int iteration = 0; |
| | | 227 | | while ((uint)iteration < (uint)slice.Length && ((ch = slice[iteration]) < 128 ? ("\0\0곺ꏿ\ufffe쟿\ |
| | | 228 | | { |
| | | 229 | | iteration++; |
| | | 230 | | } |
| | | 231 | | |
| | | 232 | | if (iteration == 0) |
| | | 233 | | { |
| | | 234 | | UncaptureUntil(0); |
| | | 235 | | return false; // The input didn't match. |
| | | 236 | | } |
| | | 237 | | |
| | | 238 | | slice = slice.Slice(iteration); |
| | | 239 | | pos += iteration; |
| | | 240 | | |
| | | 241 | | charloop_ending_pos = pos; |
| | | 242 | | charloop_starting_pos++; |
| | | 243 | | goto CharLoopEnd; |
| | | 244 | | |
| | | 245 | | CharLoopBacktrack: |
| | | 246 | | UncaptureUntil(charloop_capture_pos); |
| | | 247 | | |
| | | 248 | | if (Utilities.s_hasTimeout) |
| | | 249 | | { |
| | | 250 | | base.CheckTimeout(); |
| | | 251 | | } |
| | | 252 | | |
| | | 253 | | if (charloop_starting_pos >= charloop_ending_pos) |
| | | 254 | | { |
| | | 255 | | UncaptureUntil(0); |
| | | 256 | | return false; // The input didn't match. |
| | | 257 | | } |
| | | 258 | | pos = --charloop_ending_pos; |
| | | 259 | | slice = inputSpan.Slice(pos); |
| | | 260 | | |
| | | 261 | | CharLoopEnd: |
| | | 262 | | charloop_capture_pos = base.Crawlpos(); |
| | | 263 | | //} |
| | | 264 | | |
| | | 265 | | // Loop greedily any number of times. |
| | | 266 | | //{ |
| | | 267 | | loop_iteration = 0; |
| | | 268 | | |
| | | 269 | | LoopBody: |
| | | 270 | | Utilities.StackPush(ref base.runstack!, ref stackpos, base.Crawlpos(), pos); |
| | | 271 | | |
| | | 272 | | loop_iteration++; |
| | | 273 | | |
| | | 274 | | // 1st capture group. |
| | | 275 | | { |
| | | 276 | | int capture_starting_pos = pos; |
| | | 277 | | |
| | | 278 | | // Match '.'. |
| | | 279 | | if (slice.IsEmpty || slice[0] != '.') |
| | | 280 | | { |
| | | 281 | | goto LoopIterationNoMatch; |
| | | 282 | | } |
| | | 283 | | |
| | | 284 | | // Match a character in the set [!#-'*+\-/=?^-`{-~\w] atomically at least once. |
| | | 285 | | { |
| | | 286 | | pos++; |
| | | 287 | | slice = inputSpan.Slice(pos); |
| | | 288 | | int iteration1 = 0; |
| | | 289 | | while ((uint)iteration1 < (uint)slice.Length && ((ch = slice[iteration1]) < 128 ? ("\0\0 |
| | | 290 | | { |
| | | 291 | | iteration1++; |
| | | 292 | | } |
| | | 293 | | |
| | | 294 | | if (iteration1 == 0) |
| | | 295 | | { |
| | | 296 | | goto LoopIterationNoMatch; |
| | | 297 | | } |
| | | 298 | | |
| | | 299 | | slice = slice.Slice(iteration1); |
| | | 300 | | pos += iteration1; |
| | | 301 | | } |
| | | 302 | | |
| | | 303 | | base.Capture(1, capture_starting_pos, pos); |
| | | 304 | | } |
| | | 305 | | |
| | | 306 | | |
| | | 307 | | // The loop has no upper bound. Continue iterating greedily. |
| | | 308 | | goto LoopBody; |
| | | 309 | | |
| | | 310 | | // The loop iteration failed. Put state back to the way it was before the iteration. |
| | | 311 | | LoopIterationNoMatch: |
| | | 312 | | if (--loop_iteration < 0) |
| | | 313 | | { |
| | | 314 | | // Unable to match the remainder of the expression after exhausting the loop. |
| | | 315 | | goto CharLoopBacktrack; |
| | | 316 | | } |
| | | 317 | | pos = base.runstack![--stackpos]; |
| | | 318 | | UncaptureUntil(base.runstack![--stackpos]); |
| | | 319 | | slice = inputSpan.Slice(pos); |
| | | 320 | | LoopEnd:; |
| | | 321 | | //} |
| | | 322 | | |
| | | 323 | | // Match '@'. |
| | | 324 | | if (slice.IsEmpty || slice[0] != '@') |
| | | 325 | | { |
| | | 326 | | goto LoopIterationNoMatch; |
| | | 327 | | } |
| | | 328 | | |
| | | 329 | | // 2nd capture group. |
| | | 330 | | //{ |
| | | 331 | | pos++; |
| | | 332 | | slice = inputSpan.Slice(pos); |
| | | 333 | | capture_starting_pos1 = pos; |
| | | 334 | | |
| | | 335 | | // Match with 2 alternative expressions. |
| | | 336 | | //{ |
| | | 337 | | alternation_starting_pos = pos; |
| | | 338 | | alternation_starting_capturepos = base.Crawlpos(); |
| | | 339 | | |
| | | 340 | | // Branch 0 |
| | | 341 | | //{ |
| | | 342 | | // 3rd capture group. |
| | | 343 | | //{ |
| | | 344 | | capture_starting_pos2 = pos; |
| | | 345 | | |
| | | 346 | | // Loop greedily at least once. |
| | | 347 | | //{ |
| | | 348 | | loop_iteration1 = 0; |
| | | 349 | | |
| | | 350 | | LoopBody1: |
| | | 351 | | Utilities.StackPush(ref base.runstack!, ref stackpos, base.Crawlpos(), pos); |
| | | 352 | | |
| | | 353 | | loop_iteration1++; |
| | | 354 | | |
| | | 355 | | // 4th capture group. |
| | | 356 | | { |
| | | 357 | | int capture_starting_pos3 = pos; |
| | | 358 | | |
| | | 359 | | // Match a character in the set [\-\w] atomically at least once. |
| | | 360 | | { |
| | | 361 | | int iteration2 = 0; |
| | | 362 | | while ((uint)iteration2 < (uint)slice.Length && ((ch = slice[iteration2] |
| | | 363 | | { |
| | | 364 | | iteration2++; |
| | | 365 | | } |
| | | 366 | | |
| | | 367 | | if (iteration2 == 0) |
| | | 368 | | { |
| | | 369 | | goto LoopIterationNoMatch1; |
| | | 370 | | } |
| | | 371 | | |
| | | 372 | | slice = slice.Slice(iteration2); |
| | | 373 | | pos += iteration2; |
| | | 374 | | } |
| | | 375 | | |
| | | 376 | | // Match '.'. |
| | | 377 | | if (slice.IsEmpty || slice[0] != '.') |
| | | 378 | | { |
| | | 379 | | goto LoopIterationNoMatch1; |
| | | 380 | | } |
| | | 381 | | |
| | | 382 | | pos++; |
| | | 383 | | slice = inputSpan.Slice(pos); |
| | | 384 | | base.Capture(4, capture_starting_pos3, pos); |
| | | 385 | | } |
| | | 386 | | |
| | | 387 | | |
| | | 388 | | // The loop has no upper bound. Continue iterating greedily. |
| | | 389 | | goto LoopBody1; |
| | | 390 | | |
| | | 391 | | // The loop iteration failed. Put state back to the way it was before the iterat |
| | | 392 | | LoopIterationNoMatch1: |
| | | 393 | | if (--loop_iteration1 < 0) |
| | | 394 | | { |
| | | 395 | | // Unable to match the remainder of the expression after exhausting the loop |
| | | 396 | | goto AlternationBranch; |
| | | 397 | | } |
| | | 398 | | pos = base.runstack![--stackpos]; |
| | | 399 | | UncaptureUntil(base.runstack![--stackpos]); |
| | | 400 | | slice = inputSpan.Slice(pos); |
| | | 401 | | if (loop_iteration1 == 0) |
| | | 402 | | { |
| | | 403 | | // All possible iterations have matched, but it's below the required minimum |
| | | 404 | | goto AlternationBranch; |
| | | 405 | | } |
| | | 406 | | |
| | | 407 | | LoopEnd1:; |
| | | 408 | | //} |
| | | 409 | | |
| | | 410 | | // Match an ASCII letter atomically at least 2 and at most 4 times. |
| | | 411 | | { |
| | | 412 | | int iteration3 = 0; |
| | | 413 | | while (iteration3 < 4 && (uint)iteration3 < (uint)slice.Length && char.IsAsciiLe |
| | | 414 | | { |
| | | 415 | | iteration3++; |
| | | 416 | | } |
| | | 417 | | |
| | | 418 | | if (iteration3 < 2) |
| | | 419 | | { |
| | | 420 | | goto LoopIterationNoMatch1; |
| | | 421 | | } |
| | | 422 | | |
| | | 423 | | slice = slice.Slice(iteration3); |
| | | 424 | | pos += iteration3; |
| | | 425 | | } |
| | | 426 | | |
| | | 427 | | base.Capture(3, capture_starting_pos2, pos); |
| | | 428 | | |
| | | 429 | | goto CaptureSkipBacktrack; |
| | | 430 | | |
| | | 431 | | CaptureBacktrack: |
| | | 432 | | goto LoopIterationNoMatch1; |
| | | 433 | | |
| | | 434 | | CaptureSkipBacktrack:; |
| | | 435 | | //} |
| | | 436 | | |
| | | 437 | | alternation_branch = 0; |
| | | 438 | | goto AlternationMatch; |
| | | 439 | | |
| | | 440 | | AlternationBranch: |
| | | 441 | | pos = alternation_starting_pos; |
| | | 442 | | slice = inputSpan.Slice(pos); |
| | | 443 | | UncaptureUntil(alternation_starting_capturepos); |
| | | 444 | | //} |
| | | 445 | | |
| | | 446 | | // Branch 1 |
| | | 447 | | //{ |
| | | 448 | | // 5th capture group. |
| | | 449 | | { |
| | | 450 | | capture_starting_pos4 = pos; |
| | | 451 | | |
| | | 452 | | // Loop exactly 3 times. |
| | | 453 | | { |
| | | 454 | | for (int loop_iteration2 = 0; loop_iteration2 < 3; loop_iteration2++) |
| | | 455 | | { |
| | | 456 | | // 6th capture group. |
| | | 457 | | { |
| | | 458 | | int capture_starting_pos5 = pos; |
| | | 459 | | |
| | | 460 | | // Match a character in the set [0-9] atomically at least 1 and at most |
| | | 461 | | { |
| | | 462 | | int iteration4 = 0; |
| | | 463 | | while (iteration4 < 3 && (uint)iteration4 < (uint)slice.Length && ch |
| | | 464 | | { |
| | | 465 | | iteration4++; |
| | | 466 | | } |
| | | 467 | | |
| | | 468 | | if (iteration4 == 0) |
| | | 469 | | { |
| | | 470 | | goto LoopIterationNoMatch; |
| | | 471 | | } |
| | | 472 | | |
| | | 473 | | slice = slice.Slice(iteration4); |
| | | 474 | | pos += iteration4; |
| | | 475 | | } |
| | | 476 | | |
| | | 477 | | // Match '.'. |
| | | 478 | | if (slice.IsEmpty || slice[0] != '.') |
| | | 479 | | { |
| | | 480 | | goto LoopIterationNoMatch; |
| | | 481 | | } |
| | | 482 | | |
| | | 483 | | pos++; |
| | | 484 | | slice = inputSpan.Slice(pos); |
| | | 485 | | base.Capture(6, capture_starting_pos5, pos); |
| | | 486 | | } |
| | | 487 | | } |
| | | 488 | | } |
| | | 489 | | |
| | | 490 | | // Match a character in the set [0-9] atomically at least 1 and at most 3 times. |
| | | 491 | | { |
| | | 492 | | int iteration5 = 0; |
| | | 493 | | while (iteration5 < 3 && (uint)iteration5 < (uint)slice.Length && char.IsAsciiDi |
| | | 494 | | { |
| | | 495 | | iteration5++; |
| | | 496 | | } |
| | | 497 | | |
| | | 498 | | if (iteration5 == 0) |
| | | 499 | | { |
| | | 500 | | goto LoopIterationNoMatch; |
| | | 501 | | } |
| | | 502 | | |
| | | 503 | | slice = slice.Slice(iteration5); |
| | | 504 | | pos += iteration5; |
| | | 505 | | } |
| | | 506 | | |
| | | 507 | | base.Capture(5, capture_starting_pos4, pos); |
| | | 508 | | } |
| | | 509 | | |
| | | 510 | | alternation_branch = 1; |
| | | 511 | | goto AlternationMatch; |
| | | 512 | | //} |
| | | 513 | | |
| | | 514 | | AlternationBacktrack: |
| | | 515 | | if (Utilities.s_hasTimeout) |
| | | 516 | | { |
| | | 517 | | base.CheckTimeout(); |
| | | 518 | | } |
| | | 519 | | |
| | | 520 | | switch (alternation_branch) |
| | | 521 | | { |
| | | 522 | | case 0: |
| | | 523 | | goto CaptureBacktrack; |
| | | 524 | | case 1: |
| | | 525 | | goto LoopIterationNoMatch; |
| | | 526 | | } |
| | | 527 | | |
| | | 528 | | AlternationMatch:; |
| | | 529 | | //} |
| | | 530 | | |
| | | 531 | | base.Capture(2, capture_starting_pos1, pos); |
| | | 532 | | |
| | | 533 | | goto CaptureSkipBacktrack1; |
| | | 534 | | |
| | | 535 | | CaptureBacktrack1: |
| | | 536 | | goto AlternationBacktrack; |
| | | 537 | | |
| | | 538 | | CaptureSkipBacktrack1:; |
| | | 539 | | //} |
| | | 540 | | |
| | | 541 | | // Match if at the end of the string or if before an ending newline. |
| | | 542 | | if (pos < inputSpan.Length - 1 || ((uint)pos < (uint)inputSpan.Length && inputSpan[pos] != '\n')) |
| | | 543 | | { |
| | | 544 | | goto CaptureBacktrack1; |
| | | 545 | | } |
| | | 546 | | |
| | | 547 | | // The input matched. |
| | | 548 | | base.runtextpos = pos; |
| | | 549 | | base.Capture(0, matchStart, pos); |
| | | 550 | | return true; |
| | | 551 | | |
| | | 552 | | // <summary>Undo captures until it reaches the specified capture position.</summary> |
| | | 553 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 554 | | void UncaptureUntil(int capturePosition) |
| | | 555 | | { |
| | | 556 | | while (base.Crawlpos() > capturePosition) |
| | | 557 | | { |
| | | 558 | | base.Uncapture(); |
| | | 559 | | } |
| | | 560 | | } |
| | | 561 | | } |
| | | 562 | | } |
| | | 563 | | } |
| | | 564 | | |
| | | 565 | | } |
| | | 566 | | |
| | | 567 | | /// <summary>Custom <see cref="Regex"/>-derived type for the HasNumber method.</summary> |
| | | 568 | | [GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "10.0.13.7005")] |
| | | 569 | | file sealed class HasNumber_1 : Regex |
| | | 570 | | { |
| | | 571 | | /// <summary>Cached, thread-safe singleton instance.</summary> |
| | | 572 | | internal static readonly HasNumber_1 Instance = new(); |
| | | 573 | | |
| | | 574 | | /// <summary>Initializes the instance.</summary> |
| | | 575 | | private HasNumber_1() |
| | | 576 | | { |
| | | 577 | | base.pattern = "[0-9]+"; |
| | | 578 | | base.roptions = RegexOptions.None; |
| | | 579 | | ValidateMatchTimeout(Utilities.s_defaultTimeout); |
| | | 580 | | base.internalMatchTimeout = Utilities.s_defaultTimeout; |
| | | 581 | | base.factory = new RunnerFactory(); |
| | | 582 | | base.capsize = 1; |
| | | 583 | | } |
| | | 584 | | |
| | | 585 | | /// <summary>Provides a factory for creating <see cref="RegexRunner"/> instances to be used by methods on <see c |
| | | 586 | | private sealed class RunnerFactory : RegexRunnerFactory |
| | | 587 | | { |
| | | 588 | | /// <summary>Creates an instance of a <see cref="RegexRunner"/> used by methods on <see cref="Regex"/>.</sum |
| | | 589 | | protected override RegexRunner CreateInstance() => new Runner(); |
| | | 590 | | |
| | | 591 | | /// <summary>Provides the runner that contains the custom logic implementing the specified regular expressio |
| | | 592 | | private sealed class Runner : RegexRunner |
| | | 593 | | { |
| | | 594 | | /// <summary>Scan the <paramref name="inputSpan"/> starting from base.runtextstart for the next match.</ |
| | | 595 | | /// <param name="inputSpan">The text being scanned by the regular expression.</param> |
| | | 596 | | protected override void Scan(ReadOnlySpan<char> inputSpan) |
| | | 597 | | { |
| | | 598 | | // Search until we can't find a valid starting position, we find a match, or we reach the end of the |
| | | 599 | | while (TryFindNextPossibleStartingPosition(inputSpan) && |
| | | 600 | | !TryMatchAtCurrentPosition(inputSpan) && |
| | | 601 | | base.runtextpos != inputSpan.Length) |
| | | 602 | | { |
| | | 603 | | base.runtextpos++; |
| | | 604 | | if (Utilities.s_hasTimeout) |
| | | 605 | | { |
| | | 606 | | base.CheckTimeout(); |
| | | 607 | | } |
| | | 608 | | } |
| | | 609 | | } |
| | | 610 | | |
| | | 611 | | /// <summary>Search <paramref name="inputSpan"/> starting from base.runtextpos for the next location a m |
| | | 612 | | /// <param name="inputSpan">The text being scanned by the regular expression.</param> |
| | | 613 | | /// <returns>true if a possible match was found; false if no more matches are possible.</returns> |
| | | 614 | | private bool TryFindNextPossibleStartingPosition(ReadOnlySpan<char> inputSpan) |
| | | 615 | | { |
| | | 616 | | int pos = base.runtextpos; |
| | | 617 | | |
| | | 618 | | // Empty matches aren't possible. |
| | | 619 | | if ((uint)pos < (uint)inputSpan.Length) |
| | | 620 | | { |
| | | 621 | | // The pattern begins with a character in the set [0-9]. |
| | | 622 | | // Find the next occurrence. If it can't be found, there's no match. |
| | | 623 | | int i = inputSpan.Slice(pos).IndexOfAnyInRange('0', '9'); |
| | | 624 | | if (i >= 0) |
| | | 625 | | { |
| | | 626 | | base.runtextpos = pos + i; |
| | | 627 | | return true; |
| | | 628 | | } |
| | | 629 | | } |
| | | 630 | | |
| | | 631 | | // No match found. |
| | | 632 | | base.runtextpos = inputSpan.Length; |
| | | 633 | | return false; |
| | | 634 | | } |
| | | 635 | | |
| | | 636 | | /// <summary>Determine whether <paramref name="inputSpan"/> at base.runtextpos is a match for the regula |
| | | 637 | | /// <param name="inputSpan">The text being scanned by the regular expression.</param> |
| | | 638 | | /// <returns>true if the regular expression matches at the current position; otherwise, false.</returns> |
| | | 639 | | private bool TryMatchAtCurrentPosition(ReadOnlySpan<char> inputSpan) |
| | | 640 | | { |
| | | 641 | | int pos = base.runtextpos; |
| | | 642 | | int matchStart = pos; |
| | | 643 | | ReadOnlySpan<char> slice = inputSpan.Slice(pos); |
| | | 644 | | |
| | | 645 | | // Match a character in the set [0-9] atomically at least once. |
| | | 646 | | { |
| | | 647 | | int iteration = slice.IndexOfAnyExceptInRange('0', '9'); |
| | | 648 | | if (iteration < 0) |
| | | 649 | | { |
| | | 650 | | iteration = slice.Length; |
| | | 651 | | } |
| | | 652 | | |
| | | 653 | | if (iteration == 0) |
| | | 654 | | { |
| | | 655 | | return false; // The input didn't match. |
| | | 656 | | } |
| | | 657 | | |
| | | 658 | | slice = slice.Slice(iteration); |
| | | 659 | | pos += iteration; |
| | | 660 | | } |
| | | 661 | | |
| | | 662 | | // The input matched. |
| | | 663 | | base.runtextpos = pos; |
| | | 664 | | base.Capture(0, matchStart, pos); |
| | | 665 | | return true; |
| | | 666 | | } |
| | | 667 | | } |
| | | 668 | | } |
| | | 669 | | |
| | | 670 | | } |
| | | 671 | | |
| | | 672 | | /// <summary>Custom <see cref="Regex"/>-derived type for the HasLowerChar method.</summary> |
| | | 673 | | [GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "10.0.13.7005")] |
| | | 674 | | file sealed class HasLowerChar_2 : Regex |
| | | 675 | | { |
| | | 676 | | /// <summary>Cached, thread-safe singleton instance.</summary> |
| | | 677 | | internal static readonly HasLowerChar_2 Instance = new(); |
| | | 678 | | |
| | | 679 | | /// <summary>Initializes the instance.</summary> |
| | | 680 | | private HasLowerChar_2() |
| | | 681 | | { |
| | | 682 | | base.pattern = "[a-z]+"; |
| | | 683 | | base.roptions = RegexOptions.None; |
| | | 684 | | ValidateMatchTimeout(Utilities.s_defaultTimeout); |
| | | 685 | | base.internalMatchTimeout = Utilities.s_defaultTimeout; |
| | | 686 | | base.factory = new RunnerFactory(); |
| | | 687 | | base.capsize = 1; |
| | | 688 | | } |
| | | 689 | | |
| | | 690 | | /// <summary>Provides a factory for creating <see cref="RegexRunner"/> instances to be used by methods on <see c |
| | | 691 | | private sealed class RunnerFactory : RegexRunnerFactory |
| | | 692 | | { |
| | | 693 | | /// <summary>Creates an instance of a <see cref="RegexRunner"/> used by methods on <see cref="Regex"/>.</sum |
| | | 694 | | protected override RegexRunner CreateInstance() => new Runner(); |
| | | 695 | | |
| | | 696 | | /// <summary>Provides the runner that contains the custom logic implementing the specified regular expressio |
| | | 697 | | private sealed class Runner : RegexRunner |
| | | 698 | | { |
| | | 699 | | /// <summary>Scan the <paramref name="inputSpan"/> starting from base.runtextstart for the next match.</ |
| | | 700 | | /// <param name="inputSpan">The text being scanned by the regular expression.</param> |
| | | 701 | | protected override void Scan(ReadOnlySpan<char> inputSpan) |
| | | 702 | | { |
| | | 703 | | // Search until we can't find a valid starting position, we find a match, or we reach the end of the |
| | | 704 | | while (TryFindNextPossibleStartingPosition(inputSpan) && |
| | | 705 | | !TryMatchAtCurrentPosition(inputSpan) && |
| | | 706 | | base.runtextpos != inputSpan.Length) |
| | | 707 | | { |
| | | 708 | | base.runtextpos++; |
| | | 709 | | if (Utilities.s_hasTimeout) |
| | | 710 | | { |
| | | 711 | | base.CheckTimeout(); |
| | | 712 | | } |
| | | 713 | | } |
| | | 714 | | } |
| | | 715 | | |
| | | 716 | | /// <summary>Search <paramref name="inputSpan"/> starting from base.runtextpos for the next location a m |
| | | 717 | | /// <param name="inputSpan">The text being scanned by the regular expression.</param> |
| | | 718 | | /// <returns>true if a possible match was found; false if no more matches are possible.</returns> |
| | | 719 | | private bool TryFindNextPossibleStartingPosition(ReadOnlySpan<char> inputSpan) |
| | | 720 | | { |
| | | 721 | | int pos = base.runtextpos; |
| | | 722 | | |
| | | 723 | | // Empty matches aren't possible. |
| | | 724 | | if ((uint)pos < (uint)inputSpan.Length) |
| | | 725 | | { |
| | | 726 | | // The pattern begins with a character in the set [a-z]. |
| | | 727 | | // Find the next occurrence. If it can't be found, there's no match. |
| | | 728 | | int i = inputSpan.Slice(pos).IndexOfAnyInRange('a', 'z'); |
| | | 729 | | if (i >= 0) |
| | | 730 | | { |
| | | 731 | | base.runtextpos = pos + i; |
| | | 732 | | return true; |
| | | 733 | | } |
| | | 734 | | } |
| | | 735 | | |
| | | 736 | | // No match found. |
| | | 737 | | base.runtextpos = inputSpan.Length; |
| | | 738 | | return false; |
| | | 739 | | } |
| | | 740 | | |
| | | 741 | | /// <summary>Determine whether <paramref name="inputSpan"/> at base.runtextpos is a match for the regula |
| | | 742 | | /// <param name="inputSpan">The text being scanned by the regular expression.</param> |
| | | 743 | | /// <returns>true if the regular expression matches at the current position; otherwise, false.</returns> |
| | | 744 | | private bool TryMatchAtCurrentPosition(ReadOnlySpan<char> inputSpan) |
| | | 745 | | { |
| | | 746 | | int pos = base.runtextpos; |
| | | 747 | | int matchStart = pos; |
| | | 748 | | ReadOnlySpan<char> slice = inputSpan.Slice(pos); |
| | | 749 | | |
| | | 750 | | // Match a character in the set [a-z] atomically at least once. |
| | | 751 | | { |
| | | 752 | | int iteration = slice.IndexOfAnyExceptInRange('a', 'z'); |
| | | 753 | | if (iteration < 0) |
| | | 754 | | { |
| | | 755 | | iteration = slice.Length; |
| | | 756 | | } |
| | | 757 | | |
| | | 758 | | if (iteration == 0) |
| | | 759 | | { |
| | | 760 | | return false; // The input didn't match. |
| | | 761 | | } |
| | | 762 | | |
| | | 763 | | slice = slice.Slice(iteration); |
| | | 764 | | pos += iteration; |
| | | 765 | | } |
| | | 766 | | |
| | | 767 | | // The input matched. |
| | | 768 | | base.runtextpos = pos; |
| | | 769 | | base.Capture(0, matchStart, pos); |
| | | 770 | | return true; |
| | | 771 | | } |
| | | 772 | | } |
| | | 773 | | } |
| | | 774 | | |
| | | 775 | | } |
| | | 776 | | |
| | | 777 | | /// <summary>Custom <see cref="Regex"/>-derived type for the HasUpperChar method.</summary> |
| | | 778 | | [GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "10.0.13.7005")] |
| | | 779 | | file sealed class HasUpperChar_3 : Regex |
| | | 780 | | { |
| | | 781 | | /// <summary>Cached, thread-safe singleton instance.</summary> |
| | 1 | 782 | | internal static readonly HasUpperChar_3 Instance = new(); |
| | | 783 | | |
| | | 784 | | /// <summary>Initializes the instance.</summary> |
| | 1 | 785 | | private HasUpperChar_3() |
| | 1 | 786 | | { |
| | 1 | 787 | | base.pattern = "[A-Z]+"; |
| | 1 | 788 | | base.roptions = RegexOptions.None; |
| | 1 | 789 | | ValidateMatchTimeout(Utilities.s_defaultTimeout); |
| | 1 | 790 | | base.internalMatchTimeout = Utilities.s_defaultTimeout; |
| | 1 | 791 | | base.factory = new RunnerFactory(); |
| | 1 | 792 | | base.capsize = 1; |
| | 1 | 793 | | } |
| | | 794 | | |
| | | 795 | | /// <summary>Provides a factory for creating <see cref="RegexRunner"/> instances to be used by methods on <see c |
| | | 796 | | private sealed class RunnerFactory : RegexRunnerFactory |
| | | 797 | | { |
| | | 798 | | /// <summary>Creates an instance of a <see cref="RegexRunner"/> used by methods on <see cref="Regex"/>.</sum |
| | 1 | 799 | | protected override RegexRunner CreateInstance() => new Runner(); |
| | | 800 | | |
| | | 801 | | /// <summary>Provides the runner that contains the custom logic implementing the specified regular expressio |
| | | 802 | | private sealed class Runner : RegexRunner |
| | | 803 | | { |
| | | 804 | | /// <summary>Scan the <paramref name="inputSpan"/> starting from base.runtextstart for the next match.</ |
| | | 805 | | /// <param name="inputSpan">The text being scanned by the regular expression.</param> |
| | | 806 | | protected override void Scan(ReadOnlySpan<char> inputSpan) |
| | 2 | 807 | | { |
| | | 808 | | // Search until we can't find a valid starting position, we find a match, or we reach the end of the |
| | 2 | 809 | | while (TryFindNextPossibleStartingPosition(inputSpan) && |
| | 2 | 810 | | !TryMatchAtCurrentPosition(inputSpan) && |
| | 2 | 811 | | base.runtextpos != inputSpan.Length) |
| | 0 | 812 | | { |
| | 0 | 813 | | base.runtextpos++; |
| | 0 | 814 | | if (Utilities.s_hasTimeout) |
| | 0 | 815 | | { |
| | 0 | 816 | | base.CheckTimeout(); |
| | 0 | 817 | | } |
| | 0 | 818 | | } |
| | 2 | 819 | | } |
| | | 820 | | |
| | | 821 | | /// <summary>Search <paramref name="inputSpan"/> starting from base.runtextpos for the next location a m |
| | | 822 | | /// <param name="inputSpan">The text being scanned by the regular expression.</param> |
| | | 823 | | /// <returns>true if a possible match was found; false if no more matches are possible.</returns> |
| | | 824 | | private bool TryFindNextPossibleStartingPosition(ReadOnlySpan<char> inputSpan) |
| | 2 | 825 | | { |
| | 2 | 826 | | int pos = base.runtextpos; |
| | | 827 | | |
| | | 828 | | // Empty matches aren't possible. |
| | 2 | 829 | | if ((uint)pos < (uint)inputSpan.Length) |
| | 2 | 830 | | { |
| | | 831 | | // The pattern begins with a character in the set [A-Z]. |
| | | 832 | | // Find the next occurrence. If it can't be found, there's no match. |
| | 2 | 833 | | int i = inputSpan.Slice(pos).IndexOfAnyInRange('A', 'Z'); |
| | 2 | 834 | | if (i >= 0) |
| | 1 | 835 | | { |
| | 1 | 836 | | base.runtextpos = pos + i; |
| | 1 | 837 | | return true; |
| | | 838 | | } |
| | 1 | 839 | | } |
| | | 840 | | |
| | | 841 | | // No match found. |
| | 1 | 842 | | base.runtextpos = inputSpan.Length; |
| | 1 | 843 | | return false; |
| | 2 | 844 | | } |
| | | 845 | | |
| | | 846 | | /// <summary>Determine whether <paramref name="inputSpan"/> at base.runtextpos is a match for the regula |
| | | 847 | | /// <param name="inputSpan">The text being scanned by the regular expression.</param> |
| | | 848 | | /// <returns>true if the regular expression matches at the current position; otherwise, false.</returns> |
| | | 849 | | private bool TryMatchAtCurrentPosition(ReadOnlySpan<char> inputSpan) |
| | 1 | 850 | | { |
| | 1 | 851 | | int pos = base.runtextpos; |
| | 1 | 852 | | int matchStart = pos; |
| | 1 | 853 | | ReadOnlySpan<char> slice = inputSpan.Slice(pos); |
| | | 854 | | |
| | | 855 | | // Match a character in the set [A-Z] atomically at least once. |
| | 1 | 856 | | { |
| | 1 | 857 | | int iteration = slice.IndexOfAnyExceptInRange('A', 'Z'); |
| | 1 | 858 | | if (iteration < 0) |
| | 1 | 859 | | { |
| | 1 | 860 | | iteration = slice.Length; |
| | 1 | 861 | | } |
| | | 862 | | |
| | 1 | 863 | | if (iteration == 0) |
| | 0 | 864 | | { |
| | 0 | 865 | | return false; // The input didn't match. |
| | | 866 | | } |
| | | 867 | | |
| | 1 | 868 | | slice = slice.Slice(iteration); |
| | 1 | 869 | | pos += iteration; |
| | 1 | 870 | | } |
| | | 871 | | |
| | | 872 | | // The input matched. |
| | 1 | 873 | | base.runtextpos = pos; |
| | 1 | 874 | | base.Capture(0, matchStart, pos); |
| | 1 | 875 | | return true; |
| | 1 | 876 | | } |
| | | 877 | | } |
| | | 878 | | } |
| | | 879 | | |
| | | 880 | | } |
| | | 881 | | |
| | | 882 | | /// <summary>Custom <see cref="Regex"/>-derived type for the HasNumberLowerAndUpperChar method.</summary> |
| | | 883 | | [GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "10.0.13.7005")] |
| | | 884 | | file sealed class HasNumberLowerAndUpperChar_4 : Regex |
| | | 885 | | { |
| | | 886 | | /// <summary>Cached, thread-safe singleton instance.</summary> |
| | | 887 | | internal static readonly HasNumberLowerAndUpperChar_4 Instance = new(); |
| | | 888 | | |
| | | 889 | | /// <summary>Initializes the instance.</summary> |
| | | 890 | | private HasNumberLowerAndUpperChar_4() |
| | | 891 | | { |
| | | 892 | | base.pattern = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d).+$"; |
| | | 893 | | base.roptions = RegexOptions.None; |
| | | 894 | | ValidateMatchTimeout(Utilities.s_defaultTimeout); |
| | | 895 | | base.internalMatchTimeout = Utilities.s_defaultTimeout; |
| | | 896 | | base.factory = new RunnerFactory(); |
| | | 897 | | base.capsize = 1; |
| | | 898 | | } |
| | | 899 | | |
| | | 900 | | /// <summary>Provides a factory for creating <see cref="RegexRunner"/> instances to be used by methods on <see c |
| | | 901 | | private sealed class RunnerFactory : RegexRunnerFactory |
| | | 902 | | { |
| | | 903 | | /// <summary>Creates an instance of a <see cref="RegexRunner"/> used by methods on <see cref="Regex"/>.</sum |
| | | 904 | | protected override RegexRunner CreateInstance() => new Runner(); |
| | | 905 | | |
| | | 906 | | /// <summary>Provides the runner that contains the custom logic implementing the specified regular expressio |
| | | 907 | | private sealed class Runner : RegexRunner |
| | | 908 | | { |
| | | 909 | | /// <summary>Scan the <paramref name="inputSpan"/> starting from base.runtextstart for the next match.</ |
| | | 910 | | /// <param name="inputSpan">The text being scanned by the regular expression.</param> |
| | | 911 | | protected override void Scan(ReadOnlySpan<char> inputSpan) |
| | | 912 | | { |
| | | 913 | | // The pattern is anchored. Validate the current position and try to match at it only. |
| | | 914 | | if (TryFindNextPossibleStartingPosition(inputSpan) && !TryMatchAtCurrentPosition(inputSpan)) |
| | | 915 | | { |
| | | 916 | | base.runtextpos = inputSpan.Length; |
| | | 917 | | } |
| | | 918 | | } |
| | | 919 | | |
| | | 920 | | /// <summary>Search <paramref name="inputSpan"/> starting from base.runtextpos for the next location a m |
| | | 921 | | /// <param name="inputSpan">The text being scanned by the regular expression.</param> |
| | | 922 | | /// <returns>true if a possible match was found; false if no more matches are possible.</returns> |
| | | 923 | | private bool TryFindNextPossibleStartingPosition(ReadOnlySpan<char> inputSpan) |
| | | 924 | | { |
| | | 925 | | int pos = base.runtextpos; |
| | | 926 | | |
| | | 927 | | // Empty matches aren't possible. |
| | | 928 | | if ((uint)pos < (uint)inputSpan.Length) |
| | | 929 | | { |
| | | 930 | | // The pattern leads with a beginning (\A) anchor. |
| | | 931 | | if (pos == 0) |
| | | 932 | | { |
| | | 933 | | return true; |
| | | 934 | | } |
| | | 935 | | } |
| | | 936 | | |
| | | 937 | | // No match found. |
| | | 938 | | base.runtextpos = inputSpan.Length; |
| | | 939 | | return false; |
| | | 940 | | } |
| | | 941 | | |
| | | 942 | | /// <summary>Determine whether <paramref name="inputSpan"/> at base.runtextpos is a match for the regula |
| | | 943 | | /// <param name="inputSpan">The text being scanned by the regular expression.</param> |
| | | 944 | | /// <returns>true if the regular expression matches at the current position; otherwise, false.</returns> |
| | | 945 | | private bool TryMatchAtCurrentPosition(ReadOnlySpan<char> inputSpan) |
| | | 946 | | { |
| | | 947 | | int pos = base.runtextpos; |
| | | 948 | | int matchStart = pos; |
| | | 949 | | int charloop_starting_pos = 0, charloop_ending_pos = 0; |
| | | 950 | | int charloop_starting_pos1 = 0, charloop_ending_pos1 = 0; |
| | | 951 | | int charloop_starting_pos2 = 0, charloop_ending_pos2 = 0; |
| | | 952 | | int charloop_starting_pos3 = 0, charloop_ending_pos3 = 0; |
| | | 953 | | int stackpos = 0; |
| | | 954 | | ReadOnlySpan<char> slice = inputSpan.Slice(pos); |
| | | 955 | | |
| | | 956 | | // Match if at the beginning of the string. |
| | | 957 | | if (pos != 0) |
| | | 958 | | { |
| | | 959 | | return false; // The input didn't match. |
| | | 960 | | } |
| | | 961 | | |
| | | 962 | | // Zero-width positive lookahead. |
| | | 963 | | { |
| | | 964 | | int positivelookahead_starting_pos = pos; |
| | | 965 | | |
| | | 966 | | if (Utilities.s_hasTimeout) |
| | | 967 | | { |
| | | 968 | | base.CheckTimeout(); |
| | | 969 | | } |
| | | 970 | | |
| | | 971 | | int atomic_stackpos = stackpos; |
| | | 972 | | |
| | | 973 | | // Match a character other than '\n' greedily any number of times. |
| | | 974 | | //{ |
| | | 975 | | charloop_starting_pos = pos; |
| | | 976 | | |
| | | 977 | | int iteration = slice.IndexOf('\n'); |
| | | 978 | | if (iteration < 0) |
| | | 979 | | { |
| | | 980 | | iteration = slice.Length; |
| | | 981 | | } |
| | | 982 | | |
| | | 983 | | slice = slice.Slice(iteration); |
| | | 984 | | pos += iteration; |
| | | 985 | | |
| | | 986 | | charloop_ending_pos = pos; |
| | | 987 | | goto CharLoopEnd; |
| | | 988 | | |
| | | 989 | | CharLoopBacktrack: |
| | | 990 | | |
| | | 991 | | if (Utilities.s_hasTimeout) |
| | | 992 | | { |
| | | 993 | | base.CheckTimeout(); |
| | | 994 | | } |
| | | 995 | | |
| | | 996 | | if (charloop_starting_pos >= charloop_ending_pos || |
| | | 997 | | (charloop_ending_pos = inputSpan.Slice(charloop_starting_pos, charloop_ending_pos - char |
| | | 998 | | { |
| | | 999 | | return false; // The input didn't match. |
| | | 1000 | | } |
| | | 1001 | | charloop_ending_pos += charloop_starting_pos; |
| | | 1002 | | pos = charloop_ending_pos; |
| | | 1003 | | slice = inputSpan.Slice(pos); |
| | | 1004 | | |
| | | 1005 | | CharLoopEnd: |
| | | 1006 | | //} |
| | | 1007 | | |
| | | 1008 | | // Match a character in the set [a-z]. |
| | | 1009 | | if (slice.IsEmpty || !char.IsAsciiLetterLower(slice[0])) |
| | | 1010 | | { |
| | | 1011 | | goto CharLoopBacktrack; |
| | | 1012 | | } |
| | | 1013 | | |
| | | 1014 | | stackpos = atomic_stackpos; |
| | | 1015 | | |
| | | 1016 | | pos = positivelookahead_starting_pos; |
| | | 1017 | | slice = inputSpan.Slice(pos); |
| | | 1018 | | } |
| | | 1019 | | |
| | | 1020 | | // Zero-width positive lookahead. |
| | | 1021 | | { |
| | | 1022 | | int positivelookahead_starting_pos1 = pos; |
| | | 1023 | | |
| | | 1024 | | if (Utilities.s_hasTimeout) |
| | | 1025 | | { |
| | | 1026 | | base.CheckTimeout(); |
| | | 1027 | | } |
| | | 1028 | | |
| | | 1029 | | int atomic_stackpos1 = stackpos; |
| | | 1030 | | |
| | | 1031 | | // Match a character other than '\n' greedily any number of times. |
| | | 1032 | | //{ |
| | | 1033 | | charloop_starting_pos1 = pos; |
| | | 1034 | | |
| | | 1035 | | int iteration1 = slice.IndexOf('\n'); |
| | | 1036 | | if (iteration1 < 0) |
| | | 1037 | | { |
| | | 1038 | | iteration1 = slice.Length; |
| | | 1039 | | } |
| | | 1040 | | |
| | | 1041 | | slice = slice.Slice(iteration1); |
| | | 1042 | | pos += iteration1; |
| | | 1043 | | |
| | | 1044 | | charloop_ending_pos1 = pos; |
| | | 1045 | | goto CharLoopEnd1; |
| | | 1046 | | |
| | | 1047 | | CharLoopBacktrack1: |
| | | 1048 | | |
| | | 1049 | | if (Utilities.s_hasTimeout) |
| | | 1050 | | { |
| | | 1051 | | base.CheckTimeout(); |
| | | 1052 | | } |
| | | 1053 | | |
| | | 1054 | | if (charloop_starting_pos1 >= charloop_ending_pos1 || |
| | | 1055 | | (charloop_ending_pos1 = inputSpan.Slice(charloop_starting_pos1, charloop_ending_pos1 - c |
| | | 1056 | | { |
| | | 1057 | | return false; // The input didn't match. |
| | | 1058 | | } |
| | | 1059 | | charloop_ending_pos1 += charloop_starting_pos1; |
| | | 1060 | | pos = charloop_ending_pos1; |
| | | 1061 | | slice = inputSpan.Slice(pos); |
| | | 1062 | | |
| | | 1063 | | CharLoopEnd1: |
| | | 1064 | | //} |
| | | 1065 | | |
| | | 1066 | | // Match a character in the set [A-Z]. |
| | | 1067 | | if (slice.IsEmpty || !char.IsAsciiLetterUpper(slice[0])) |
| | | 1068 | | { |
| | | 1069 | | goto CharLoopBacktrack1; |
| | | 1070 | | } |
| | | 1071 | | |
| | | 1072 | | stackpos = atomic_stackpos1; |
| | | 1073 | | |
| | | 1074 | | pos = positivelookahead_starting_pos1; |
| | | 1075 | | slice = inputSpan.Slice(pos); |
| | | 1076 | | } |
| | | 1077 | | |
| | | 1078 | | // Zero-width positive lookahead. |
| | | 1079 | | { |
| | | 1080 | | int positivelookahead_starting_pos2 = pos; |
| | | 1081 | | |
| | | 1082 | | if (Utilities.s_hasTimeout) |
| | | 1083 | | { |
| | | 1084 | | base.CheckTimeout(); |
| | | 1085 | | } |
| | | 1086 | | |
| | | 1087 | | int atomic_stackpos2 = stackpos; |
| | | 1088 | | |
| | | 1089 | | // Match a character other than '\n' greedily any number of times. |
| | | 1090 | | //{ |
| | | 1091 | | charloop_starting_pos2 = pos; |
| | | 1092 | | |
| | | 1093 | | int iteration2 = slice.IndexOf('\n'); |
| | | 1094 | | if (iteration2 < 0) |
| | | 1095 | | { |
| | | 1096 | | iteration2 = slice.Length; |
| | | 1097 | | } |
| | | 1098 | | |
| | | 1099 | | slice = slice.Slice(iteration2); |
| | | 1100 | | pos += iteration2; |
| | | 1101 | | |
| | | 1102 | | charloop_ending_pos2 = pos; |
| | | 1103 | | goto CharLoopEnd2; |
| | | 1104 | | |
| | | 1105 | | CharLoopBacktrack2: |
| | | 1106 | | |
| | | 1107 | | if (Utilities.s_hasTimeout) |
| | | 1108 | | { |
| | | 1109 | | base.CheckTimeout(); |
| | | 1110 | | } |
| | | 1111 | | |
| | | 1112 | | if (charloop_starting_pos2 >= charloop_ending_pos2) |
| | | 1113 | | { |
| | | 1114 | | return false; // The input didn't match. |
| | | 1115 | | } |
| | | 1116 | | pos = --charloop_ending_pos2; |
| | | 1117 | | slice = inputSpan.Slice(pos); |
| | | 1118 | | |
| | | 1119 | | CharLoopEnd2: |
| | | 1120 | | //} |
| | | 1121 | | |
| | | 1122 | | // Match a Unicode digit. |
| | | 1123 | | if (slice.IsEmpty || !char.IsDigit(slice[0])) |
| | | 1124 | | { |
| | | 1125 | | goto CharLoopBacktrack2; |
| | | 1126 | | } |
| | | 1127 | | |
| | | 1128 | | stackpos = atomic_stackpos2; |
| | | 1129 | | |
| | | 1130 | | pos = positivelookahead_starting_pos2; |
| | | 1131 | | slice = inputSpan.Slice(pos); |
| | | 1132 | | } |
| | | 1133 | | |
| | | 1134 | | // Match a character other than '\n' greedily at least once. |
| | | 1135 | | //{ |
| | | 1136 | | charloop_starting_pos3 = pos; |
| | | 1137 | | |
| | | 1138 | | int iteration3 = slice.IndexOf('\n'); |
| | | 1139 | | if (iteration3 < 0) |
| | | 1140 | | { |
| | | 1141 | | iteration3 = slice.Length; |
| | | 1142 | | } |
| | | 1143 | | |
| | | 1144 | | if (iteration3 == 0) |
| | | 1145 | | { |
| | | 1146 | | return false; // The input didn't match. |
| | | 1147 | | } |
| | | 1148 | | |
| | | 1149 | | slice = slice.Slice(iteration3); |
| | | 1150 | | pos += iteration3; |
| | | 1151 | | |
| | | 1152 | | charloop_ending_pos3 = pos; |
| | | 1153 | | charloop_starting_pos3++; |
| | | 1154 | | goto CharLoopEnd3; |
| | | 1155 | | |
| | | 1156 | | CharLoopBacktrack3: |
| | | 1157 | | |
| | | 1158 | | if (Utilities.s_hasTimeout) |
| | | 1159 | | { |
| | | 1160 | | base.CheckTimeout(); |
| | | 1161 | | } |
| | | 1162 | | |
| | | 1163 | | if (charloop_starting_pos3 >= charloop_ending_pos3) |
| | | 1164 | | { |
| | | 1165 | | return false; // The input didn't match. |
| | | 1166 | | } |
| | | 1167 | | pos = --charloop_ending_pos3; |
| | | 1168 | | slice = inputSpan.Slice(pos); |
| | | 1169 | | |
| | | 1170 | | CharLoopEnd3: |
| | | 1171 | | //} |
| | | 1172 | | |
| | | 1173 | | // Match if at the end of the string or if before an ending newline. |
| | | 1174 | | if (pos < inputSpan.Length - 1 || ((uint)pos < (uint)inputSpan.Length && inputSpan[pos] != '\n')) |
| | | 1175 | | { |
| | | 1176 | | goto CharLoopBacktrack3; |
| | | 1177 | | } |
| | | 1178 | | |
| | | 1179 | | // The input matched. |
| | | 1180 | | base.runtextpos = pos; |
| | | 1181 | | base.Capture(0, matchStart, pos); |
| | | 1182 | | return true; |
| | | 1183 | | } |
| | | 1184 | | } |
| | | 1185 | | } |
| | | 1186 | | |
| | | 1187 | | } |
| | | 1188 | | |
| | | 1189 | | /// <summary>Helper methods used by generated <see cref="Regex"/>-derived implementations.</summary> |
| | | 1190 | | [GeneratedCodeAttribute("System.Text.RegularExpressions.Generator", "10.0.13.7005")] |
| | | 1191 | | file static class Utilities |
| | | 1192 | | { |
| | | 1193 | | /// <summary>Default timeout value set in <see cref="AppContext"/>, or <see cref="Regex.InfiniteMatchTimeout"/> |
| | | 1194 | | internal static readonly TimeSpan s_defaultTimeout = AppContext.GetData("REGEX_DEFAULT_MATCH_TIMEOUT") is TimeSp |
| | | 1195 | | |
| | | 1196 | | /// <summary>Whether <see cref="s_defaultTimeout"/> is non-infinite.</summary> |
| | | 1197 | | internal static readonly bool s_hasTimeout = s_defaultTimeout != Regex.InfiniteMatchTimeout; |
| | | 1198 | | |
| | | 1199 | | /// <summary>Pushes 2 values onto the backtracking stack.</summary> |
| | | 1200 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | | 1201 | | internal static void StackPush(ref int[] stack, ref int pos, int arg0, int arg1) |
| | | 1202 | | { |
| | | 1203 | | // If there's space available for all 2 values, store them. |
| | | 1204 | | int[] s = stack; |
| | | 1205 | | int p = pos; |
| | | 1206 | | if ((uint)(p + 1) < (uint)s.Length) |
| | | 1207 | | { |
| | | 1208 | | s[p] = arg0; |
| | | 1209 | | s[p + 1] = arg1; |
| | | 1210 | | pos += 2; |
| | | 1211 | | return; |
| | | 1212 | | } |
| | | 1213 | | |
| | | 1214 | | // Otherwise, resize the stack to make room and try again. |
| | | 1215 | | WithResize(ref stack, ref pos, arg0, arg1); |
| | | 1216 | | |
| | | 1217 | | // <summary>Resize the backtracking stack array and push 2 values onto the stack.</summary> |
| | | 1218 | | [MethodImpl(MethodImplOptions.NoInlining)] |
| | | 1219 | | static void WithResize(ref int[] stack, ref int pos, int arg0, int arg1) |
| | | 1220 | | { |
| | | 1221 | | Array.Resize(ref stack, (pos + 1) * 2); |
| | | 1222 | | StackPush(ref stack, ref pos, arg0, arg1); |
| | | 1223 | | } |
| | | 1224 | | } |
| | | 1225 | | } |
| | | 1226 | | } |