Validate hex color

Published on Tue Mar 01 2022

Validates hexadecimal color codes based on the following rule set: - Optionally starting with a hash. - 3 or 6 characters in length. - Using the [0-9a-f] character set.

Additional matching regexes for
Validate hex color

Validate hex color

Validates hexadecimal color codes based on the following rule set: - Optionally starting with a hash. - 3 or 6 characters in length. - Using the [0-9a-f] character set.

German ZIP Validation

Validates German ZIP codes

Validates argentinian postal code

Validates the two valid postal codes in Argentina

Mobile Number Regex

The following regex validates international mobile numbers

Simple title validation

Used to validate entries like Address names and cities, streets. - Allows any of the following characters `-.#@&,:?!]{2})[a-zA-Z0-9- .#@&,_'":.?!` - Prohibits these characters from begining a sentence ` -.&,_'":?!` - Prohibits these characters from ending a sentence `- &_'":`

URL Validator

Validates - 1. URLs with schemes - http, https and ftp 2. Relative URL starting with / and ../

Color RegEx

Color RegEx

Invalid Unicode characters in XML

This pattern matches all the Unicode characters that are not allowed in an XML document. It's based on the Wikipedia article "Valid characters in XML".

html color match: transparent, #fff, #123456, rgb, rgba, hsl, hsla

This may be useful or not to test whether a given string is a valid (more or less) html color value. It matches color values such as: - #123 - short hex color value - #123456 - hex color value - rgb(255,255,0) - rgb color value - rgba(255,255,0,1.0) - rgba color value - hsl(360,100%,100%) - hsl color value - hsla(360,100%,100%,0.5334) - hsla color value Regex allows whitespaces between i.e. rgb and (, also between numbers and commas, but not in value like 55% between number and percentage. To change this behaviour simply remove \s*? from appriopriate places.

Guid (with or without dashes)

Matches a guid string that can optionally include dashes.