+ 1

# regular expressions

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"?

6 Answers

+ 1

Ok. 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.

+ 2

This can be done exactly as you said in the question.

+ 2

This is a short code for test of your input [user id=16063996]Mary_d9[/user] with in your question mentioned requested sequences:
https://code.sololearn.com/W464rI07K52h/?ref=app

0

Two questions: will there always be 3 numbers, or will the number vary, and what language are you using?

0

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.

0

Russ thank you!

Hot today

What is indentations... ?

6 Votes

int num = 2;
int x = 3;
if(num >= 2) {
if(x > 4) { num = 3; }
else { num = 4; }
}
else {x = 1; }

1 Votes

Need solution

0 Votes

About Java McQ

0 Votes

Need solution

0 Votes

YouTube Link Finder

0 Votes