Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
418 views
in Technique[技术] by (71.8m points)

js,求一条正则该怎么写

'160px'.replace(/xxx/,'') => '160'
'160.66px'.replace(/xxx/,'') => '160'

求解一条正则上面两种情况都能满足


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
// => 160
'160px'.replace(/(^d+)(.*)/, '$1')

// => 160
'160.66pxpx'.replace(/(^d+)(.*)/, '$1')

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...