0

Can u all please help me out to get the regex for the range 900 to 864000 thank you

Haris
  • 12,120
  • 6
  • 43
  • 70
  • 6
    Regex is _overkill_ here. Use Comparison `if (num >= 900 && num <= 86400)` – Tushar Nov 18 '15 at 04:23
  • hey tushar thanks for reply , but the java code i use is generic code which works for different numeric ranges,which accepts regex for the range validation , among those 900 to 864000 is one of the range – Suneil Narasimhamurthy Nov 18 '15 at 04:38

1 Answers1

1

This platform is for helping with your regex, not writing your code. You probably need to split this problem into several subsections and combine them with | pipes in an anchored group.

  1. 900-999
    to match 9 followed by two digits: 9\d\d
  2. 1000-99999
    any four or five digits: \d{4,5}
  3. 100000-799999
    1-7 followed by any 5 digits: [1-7]\d{5}
  4. 800000-859999
    eight followed by zero to five and any 4 digits: 8[0-5]\d{4}
  5. 860000-863999
    eight followed by six followed by zero to 3 and any 3 digits:
    Get coffee or better tea an try yourself!
  6. 864000

An inital lookahead (?!0) to disallow leading zeroes if desired .

unveil secret solution

bobble bubble
  • 16,888
  • 3
  • 27
  • 46