I have an input string that is a percentage value, i.e. "40%*", "90%*", etc. I wrote a regular expression to capture just the number so I can convert it to a number and do math on it (comparisons). For this I used the following regular expression, which worked fine for this type of input:
'40%*'.match(/[^%]*/)[0] // Outputs '40'
However, sometimes the input will look like this: "<10%*". Because of this edge case, my regular expression has a bug. In order to fix, I tried this:
'<10%*'.match(/[^[%<]]*/)[0] // Outputs '1'
But now it will only capture the "1" on a str.match, instead of the full "10". I am not sure why it seems like the * operator to match 0 or more characters seems to only be matching 1 character here?