-1

I'm trying to make a regex that captures a certain word can have a certain number of spaces after it and have a number right after.

Example

Created 100 images

I tried

/(created\s*\d*)/

Which matches what I want but also matches

'Created '

^No digits are after the word.

I want it to must include a digit as well

Farris Ismati
  • 176
  • 1
  • 9
  • 1
    **[Regex Quantifier Cheatsheet](http://www.rexegg.com/regex-quickstart.html#quantifiers)** and **[More Quantifier Cheatsheet](http://www.rexegg.com/regex-quickstart.html#morequants)**. Also, see [Learning Regular Expressions](http://stackoverflow.com/a/2759417/3832970). – Wiktor Stribiżew Jun 16 '16 at 13:14
  • What does `*` mean in regex? – Tom Myddeltyn Jun 16 '16 at 13:18
  • "certain number of spaces after it" - spaces should definitely be there? then you should use `\s+`. Else `created100` will get matched. – gaganso Jun 16 '16 at 13:25

1 Answers1

3

Change \d* to \d+. * means zero or more, where + means one or more.

Try it here

Morgan Thrapp
  • 9,748
  • 3
  • 46
  • 67