Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我们有一些这样的字符串并且需要它们的单位:
'rotate(90deg)' // 'deg'` 'rect(0 0 5px 5px)' // 'px' 'rgba(0, 0, 0, 0.5)' // ''
我怎样才能做到这一点?
这个应该有效:
/[0-9]+([^ ,\)`]*)/
例子 :
/[0-9]+([^ ,\)`]*)/.exec('rect(5px 0px 0px 5px)')[1]; // 'px'