Regular Expressions 101

Community Patterns

Basic Hex Capture

0

Regular Expression
PCRE2 (PHP >=7.3)

/
(?<color>\[(?<hex>[a-fA-F0-9]{6})\](?<text>[\s\w!@#$&()<>\\-`.+,\/\\\"]{0,}))
/
g

Description

Parses string to extract all hex codes in square brackets along with the text after

Submitted by anonymous - 3 years ago