Regular Expressions 101

Community Patterns

How to document a Regex? Example 2

1

Regular Expression
PCRE (PHP <7.3)

/
((?# Capturing group for the type name) \/+(?# Start with / or // ) [^\/\[\]]+(?# Type name exclusing start of attribute and next type) (?:(?# Non-capturing group for the attribute) \[(?# Start of an attribute) [^\]']*(?# Anything but end of attribute or start of string) (?:(?# non-capturing group for string) '(?# string start) [^']*(?# anything inside the string, except end of string) '(?# string end) )(?# end of string group) \](?# end of attribute) )?(?# Attribute can occur 0 or one time) )+(?# Type can occur once or many times)
/

Description

How to document a Regex? Example 2: added documentation using (?#)

Submitted by Thomas - 9 years ago