I am trying to match only the saturation value of a HSL color, for example given hsl(190, 40%, 50%)
as an input, I would like to match the 40
/40%
. I have trying using lookarounds for this, but everything I tried just didn’t really work.
I have the following regex which matches pretty much any HSL color I would need: /hsla?(s*(-?(d{1,3}|d{1,3}.d+)(deg|%)?)s*(,s*|s+)(-?(d{1,3}|d{1,3}.d+)%?)s*(,s*|s+)((d{1,3}|d{1,3}.d+)%?)s*((,s*|s*/s*)(0|(0?.d+)|1))?s*)/gi
. How would I go about only selecting the saturation value?