How to use regular expressions to find such sequences of numbers in the text: "8 9 10" or "10 10 9" or "9 9 8" or "9 8 10"?
4/12/2021 5:37:55 PM
Mary_d96 Answers
New AnswerOk. So, to make sure, for the string 'four 3 8 10 six 9 10 8 8' the correct output would be '8 10', '9 10 8 8' Is that correct? If so, '((?:(?:8|9|10)\s)*(?:8|9|10))' appears to do the trick. Not extensively tested though.
This is a short code for test of your input Mary_d9 with in your question mentioned requested sequences: https://code.sololearn.com/W464rI07K52h/?ref=app
Two questions: will there always be 3 numbers, or will the number vary, and what language are you using?
Russ The text can contain different numbers and even dates, but I only need 8, 9 and 10. There is a space separator between them. I will execute the command with regex in bash.
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message