Reputation: 3
console.log("1h2m3s".match(/\d+h/i));
The code results in 1h
but I want just the number it self. I could cut off the end, but I don't want to do that. How do I just isolate just the number part?
Upvotes: 0
Views: 35
Reputation: 521103
You could use a positive lookahead instead which checks for the h
component:
console.log("1h2m3s".match(/\d+(?=h)/i));
Upvotes: 1