I have a string logs as follow:
rgb(255, 255, 255) 0px 0px 0px 16px inset
I like to get the dynamic value, in the case above, 16. How do I write regex for the rule to match the last px
then take out the digits between px
and the space?
I have a string logs as follow:
rgb(255, 255, 255) 0px 0px 0px 16px inset
I like to get the dynamic value, in the case above, 16. How do I write regex for the rule to match the last px
then take out the digits between px
and the space?
Since you say you just want the number before the last px
, I won't assume that the text inset
is always there. I would say \b\d+(?=px\b(?!.*\b\d+px\b))
is probably your safest bet.