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

Published on Tue Mar 01 2022

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.

Additional matching regexes for
html color match: transparent, #fff, #123456, rgb, rgba, hsl, hsla

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.

Color RegEx

Color RegEx

Extract All Steam Keys

Extract all Steam Keys from a Given String

Match Between HTML Tags

Match everything within the given HTML tag

Word wrap text

(Directly inspired by https://macromates.com/blog/2006/wrapping-text-with-regular-expressions/ ) This version only splits between words, so lines may wrap earlier than the given maximum. Passes existing linefeed through "as‐is", so probably not useful for reflowing already wrapped text

Phone number tests

Test a given string for phone number variations and extract th parts.

Regex for matching assignments

Match the java assignments and get the assigned value

Fetch data between curly braces with plain text

This regex fetch only the data between content in curly braces (first occurrence, use preg_match_all in php, for all occurrences). This is useful for bad JSON files with wrong format or text between.

Element's Attribute Value in XML (simple)

Simple regular expression for extracting attribute value of the element in XML-string. Attribute value should be in quotes.

Remove GO and split for batch SQL text

Useful for when you need to convert a T-SQL MSSMS Server batch into individual SQL requests by removing the GO between them. e.g. Dim SQLBatches As String() = Regex.Split(text, "(?:\s|\r|\n)+GO\s*(?:\r|\n)", RegexOptions.IgnoreCase)