Regex to match the last float in a string

前端 未结 1 435
长情又很酷
长情又很酷 2021-01-27 08:45

I have the following string

translate3d(0px, -26px, 0px) scale(1);

And I have the following regex

(\\d+)(?!.*\\d)
相关标签:
1条回答
  • 2021-01-27 09:41

    To match float number you can use following regex

    \d+(?:\.\d+)?(?!.*\d)
    

    Regex explanation

    Regular expression visualization


    If the ending is always ); then you can use following regex

    \d+(?:\.\d+)?(?=\);$)
    

    Regex explanation

    Regular expression visualization

    0 讨论(0)
提交回复
热议问题