Use named regular expression groups to simplify shortcodes code
|Reported by:||nbachiyski||Owned by:|
// WARNING! Do not change this regex without changing do_shortcode_tag() and strip_shortcode_tag()
because these functions use the regular expression match from the shortcode parser.
Instead, we could use named regex groups: (?P<year>\d\d\d\d) or (?'year')\d\d\d\d which appear indexed by name in the matches array: $matches['year'] instead of matches.
- Future-proof code. Won't rely on indices, but on names, which we can control. Now, if we want to add a group we will have to offset all the indices, scattered all over the place.
- Less ugly and unreadable code like:
if (!empty($m)) $atts[strtolower($m)] = stripcslashes($m); elseif (!empty($m)) $atts[strtolower($m)] = stripcslashes($m);