Your Regex Brain

sln at netherlands.com sln at netherlands.com
Mon Mar 26 20:02:19 EDT 2012


On Sat, 24 Mar 2012 16:30:28 -0700 (PDT), Xah Lee <xahlee at gmail.com> wrote:

>?Your Regex Brain?
>http://xahlee.org/comp/your_regex_brain.html
>

That's more like a brain cell.
This is more like a regex brain.

'
<img 
  (?=\s) 
  (?= (?:[^>"\']|"[^"]*"|\'[^\']*\')*? (?<=\s) width \s*=
      (?: (?> \s* ([\'"]) \s* (?<WIDTH>.*?) \s* \g{-2} )
        | (?> (?!\s*[\'"]) \s* (?<WIDTH>[^\s>]*) (?=\s|>) )   
      )
  )
  (?= (?:[^>"\']|"[^"]*"|\'[^\']*\')*? (?<=\s) src \s*=
      (?: (?> \s* ([\'"]) \s* (?<SRC>.*?) \s* \g{-2} )
        | (?> (?!\s*[\'"]) \s* (?<SRC>[^\s>]*) (?=\s|>) )   
      )
  )
  (?= (?:[^>"\']|"[^"]*"|\'[^\']*\')*? (?<=\s) height \s*=
      (?: (?> \s* ([\'"]) \s* (?<HEIGHT>.*?) \s* \g{-2} )
        | (?> (?!\s*[\'"]) \s* (?<HEIGHT>[^\s>]*) (?=\s|>) )   
      )
  )
  (?= (?:[^>"\']|"[^"]*"|\'[^\']*\')*? (?<=\s) alt \s*=
      (?: (?> \s* ([\'"]) \s* (?<ALT>.*?) \s* \g{-2} )
        | (?> (?!\s*[\'"]) \s* (?<ALT>[^\s>]*) (?=\s|>) )   
      )
  )
  (?> \s+ (?:".*?"|\'.*?\'|[^>]*?)+ > ) (?<!/>)
'

-sln




More information about the Python-list mailing list