Reusable pattern to match balanced [brackets]. See Friedl's "Mastering Regular Expressions", 2nd Ed., pp. 328-331.
()
| 453 | /// "Mastering Regular Expressions", 2nd Ed., pp. 328-331. |
| 454 | /// </summary> |
| 455 | private static string GetNestedBracketsPattern() |
| 456 | { |
| 457 | // in other words [this] and [this[also]] and [this[also[too]]] |
| 458 | // up to _nestDepth |
| 459 | if (_nestedBracketsPattern == null) |
| 460 | _nestedBracketsPattern = |
| 461 | RepeatString(@" |
| 462 | (?> # Atomic matching |
| 463 | [^\[\]]+ # Anything other than brackets |
| 464 | | |
| 465 | \[ |
| 466 | ", _nestDepth) + RepeatString( |
| 467 | @" \] |
| 468 | )*" |
| 469 | , _nestDepth); |
| 470 | return _nestedBracketsPattern; |
| 471 | } |
| 472 | |
| 473 | private static string _nestedParensPattern; |
| 474 |
nothing calls this directly
no outgoing calls
no test coverage detected