Regular Expressions 101

Community Patterns

1...56789...901

Community Library Entry

3

Regular Expression
PCRE (PHP <7.3)

/
(?P<shortcode>(?:(?:\s?\[))(?P<name>[\w\-]{3,})(?:\s(?P<attrs>[\w\d,\s=\"\'\-\+\#\%\!\~\`\&\.\s\:\/\?\|]+))?(?:\])(?:(?P<html>[\w\d\,\!\@\#\$\%\^\&\*\(\\)\s\=\"\'\-\+\&\.\s\:\/\?\|\<\>]+)(?:\[\/[\w\-\_]+\]))?)
/
ug

Description

Parse shortcodes, its attributes values and html

Submitted by anonymous - 9 years ago