Regular expression, picking numbers before a text

Asked

Viewed 214 times

3

I wanted a regular expression to catch the minutes in a string with this format:

1 min
10 min

I made that expression. \d(?= min)

The problem is that it only takes the last number, the closest to the min. How would I get the all numbers?

  • 1

    And if you put one together + after \d? -> http://regexr.com/3bmpn

  • 1

    Resolve, put as answer I mark there :) Thanks!

1 answer

3


If you put a + after \d already works. That way you mean a number that occurs once or more. Being without the + means only once.

\d+(?= min)

Example: http://regexr.com/3bmpn

Browser other questions tagged

You are not signed in. Login or sign up in order to post.