I just came across the following function below:
function hexToRgb(hex){
  // By Tim Down - http://stackoverflow.com/a/5624139/3493650
  // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF")
  var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
  hex = hex.replace(shorthandRegex, function(m, r, g, b) {
     return r + r + g + g + b + b;
  });
Now I tried the following regex in my browser console:
s = "#ddd"
s.match(/^#?([a-f\d])([a-f\d])([a-f\d])$/i) // RESULT ["#ddd", "d", "d", "d"]
Now when I change s to the following:
s = "##ddd"
s.match(/^#?([a-f\d])([a-f\d])([a-f\d])$/i) // null
Why is it null? Why no match, when I check the regex in the regex checker here:
It says the following:
#? matches the character # literally Quantifier: ? Between zero and one time, as many times as possible, giving back as needed [greedy]
Now the above statement says as many times as possible , so why does ##fff not match with the regex /^#?([a-f\d])([a-f\d])([a-f\d])$/i ?
 
     
     
    