validUrlBalancedParens top-level constant

String const validUrlBalancedParens

Allow URL paths to contain up to two nested levels of balanced parens

  1. Used in Wikipedia URLs like /Primer_(film)
  2. Used in IIS sessions like /S(dfd346)/
  3. Used in Rdio URLs like /track/We_Up_(Album_Version_(Edited))/

Implementation

const validUrlBalancedParens = r'\('
    '(?:'
    '$validGeneralUrlPathChars+'
    '|'
    '(?:'
    '$validGeneralUrlPathChars*'
    r'\('
    '$validGeneralUrlPathChars+'
    r'\)'
    '$validGeneralUrlPathChars*'
    ')'
    ')'
    r'\)';