Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE2 (PHP >=7.3)

/
<!ELEMENT\s+ ((?'elname'\S+)\s+) ((?'rank'\d+)\s+)? (?'tagOmit' (?'start'[-oO])\s+ (?'end'[-oO])\s+ )? (?'content' (?'keyword'(ANY|EMPTY|CDATA|RDATA))| (?'contentGrp' \(.*\)[*+?]?) ) (?'exceptions' (\s+\-(?'exclusion'\(.+\)))? (\s+\+(?'inclusion'\(.+\)))? ) \s*>
/
gmx

Description

Parses an SGML <!ELEMENT ... >. Doesn't support name groups. Probably imperfect in other ways.

Note this is crafted for .Net as things get a little weird with # matching.

Submitted by Scott Bednar - 10 months ago