Regular Expressions 101

Community Patterns

SGML Element (.Net)

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 - 2 months ago