Iwan Kurniawan
Iwan Kurniawan

Reputation: 25

regex less than 230000

I am trying to get value less than 230001 in list and two number after space 20 or 10 and Last character is X. I tried:

[0-2][0-3][0-9][0-9][0-9][0-9] (20|10) X
-z001 230001 20 X
-z011  26321 10 *
-z002 230000 10 X
-z003 134242 12 *
-z004 199999 10 X
-z005 299999 20 X

My expected result is

-z002 230000 10 X
-z004 199999 10 X

Upvotes: 1

Views: 100

Answers (1)

Wiktor Stribiżew
Wiktor Stribiżew

Reputation: 627126

You can use

.* ([0-9]|[1-9][0-9]{1,4}|1[0-9]{5}|2[0-2][0-9]{4}|230000) [12]0 X.*

See the regex demo.

The numeric range regex is generated with this numeric range regex generator.

Details:

  • .* - any zero or more chars as many as possible
  • - space
  • ([0-9]|[1-9][0-9]{1,4}|1[0-9]{5}|2[0-2][0-9]{4}|230000) - 0 to 23000 number regex
  • - space
  • [12]0 - 1 or 2 and then 0
  • X - space, X
  • .* - any zero or more chars as many as possible.

Upvotes: 2

Related Questions