M
M
Michael Compass2021-08-11 16:44:38
Regular Expressions
Michael Compass, 2021-08-11 16:44:38

Why does the regular expression "not see" a number with one sign?

There is a text:
ago 9 minutes, 37 seconds 666,141 views
ago 9 minutes, 37 seconds 66,141 views
ago 1 hour, 10 minutes 717 views
ago 46 seconds 405 views
ago 58 seconds 8 views

There is a regular season:
https://regex101.com/r/ jmYuCb/1

Why does the regular expression not see the last line in which one character is in the number? ... Here it is actually: 8 views

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexandroppolus, 2021-08-11
@mik777em

optionality must be done through a question mark
(?<=ago).+?(?=\s+\d+(?:[,|\d+]+)?\s+views)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question