✏️ Small diff in dye's implementation of regex

This commit is contained in:
z3rOR0ne 2022-12-22 19:50:00 -08:00
parent c9f1a4a757
commit 286395a230

View file

@ -77,7 +77,7 @@ hex_to_rgb() {
# parse_rgb() takes rgb string to pass to rgb_to_hex()
parse_rgb() {
local regex='^\s?rgb[a]?[(][0-9]{1,3}, [0-9]{1,3}, [0-9]{1,3}[)]$|^rgb[a]?[(][0-9]{1,3}, [0-9]{1,3}, [0-9]{1,3}, [0-1]?.[0-9][0-9]?[)]\s?$'
local regex='^rgb[a]?[(][0-9]{1,3}, [0-9]{1,3}, [0-9]{1,3}[)]$|^rgb[a]?[(][0-9]{1,3}, [0-9]{1,3}, [0-9]{1,3}, [0-1]?.[0-9][0-9]?[)]$'
if [[ $2 =~ $regex ]]; then
local numbers
numbers=$(echo "$2" | sed -n 's/.*\(([^()]*)\).*/\1/p' | sed 's/[()]//g' | sed 's/,\s/ /g')