Regex for hex colors (#RGB / #RRGGBB)
Example pattern below—edit it or paste your own. All processing runs in your browser. For Python’s re module, switch flavor in the tool.
Standard `RegExp` for explanation and preview.
Plain-English explanation
Flavor: JavaScript RegExp
Flags: g (find all matches)
Match the character "#". Then Match one of: (1) Match one character from: characters from the character "0" to the character "9", characters from the character "a" to the character "f", characters from the character "A" to the character "F", repeated exactly 3 times. OR (2) Match one character from: characters from the character "0" to the character "9", characters from the character "a" to the character "f", characters from the character "A" to the character "F", repeated exactly 6 times. OR (3) Match one character from: characters from the character "0" to the character "9", characters from the character "a" to the character "f", characters from the character "A" to the character "F", repeated exactly 8 times. Then a word boundary