34 karma · joined Dec 28, 2010 (15y ago) · 13 submissions
comment 15y ago · link · parent
comment 15y ago · link · parent
HTML is more accurately a context-free language (CFL). A regular expression does not allow you to do any sort of counting or stack-based matching in a match, which is required to do things like "I just saw <div>...<a>...<img> so I better see "</img>...</a>...</div>" later on.
The reason the linked solution works is because of the extended capabilities of PCREs, such as backtracking and things like that.
comment 15y ago · link · parent
comment 15y ago · link · parent
comment 15y ago · link · parent