Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 893219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:11:07+00:00 2026-05-15T14:11:07+00:00

I need a regex for 5 digits in increasing order, like 12345 , 24579

  • 0

I need a regex for 5 digits in increasing order, like 12345, 24579, 34680, and so on.

0 comes after 9.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T14:11:08+00:00Added an answer on May 15, 2026 at 2:11 pm

    You can try (as seen on rubular.com)

    ^(?=\d{5}$)1?2?3?4?5?6?7?8?9?0?$
    

    Explanation

    • ^ and $ are the beginning and end of string anchors respectively
    • \d{5} is the digit character class \d repeated exactly {5} times
    • (?=...) is a positive lookahead
    • ? on each digit makes each optional

    How it works

    • First we use lookahead to assert that anchored at the beginning of the string, we can see \d{5} till the end of the string
    • Now that we know that we have 5 digits, we simply match the digits in the order we want, but making each digit optional
      • The assertion ensures that we have the correct number of digits

    regular-expressions.info

    • Anchors, Character Classes, Finite Repetition, Lookarounds, and Optional

    Generalizing the technique

    Let’s say that we need to match strings that consists of:

    • between 1-3 vowels [aeiou]
    • and the vowels must appear in order

    Then the pattern is (as seen on rubular.com):

    ^(?=[aeiou]{1,3}$)a?e?i?o?u?$
    

    Again, the way it works is that:

    • Anchored at the beginning of the string, we first assert (?=[aeiou]{1,3}$)
      • So correct alphabet in the string, and correct length
    • Then we test for each letter, in order, making each optional, until the end of the string

    Allowing repetition

    If each digit can repeat, e.g. 11223 is a match, then:

    • instead of ? (zero-or-one) on each digit,
    • we use * (zero-or-more repetition)

    That is, the pattern is (as seen on rubular.com):

    ^(?=\d{5}$)1*2*3*4*5*6*7*8*9*0*$
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a validation RegEx for decimal. It should allow up to 5 digits
I need a regex to match a string that: has only digits 0-9 and
greetings all I need the sub-domains to be something like: sub1 (letters or digits)
I need regex to check if a string contains 8 decimal digits or more.
I need the regex for following type of string: F_E/S_(characters/digits or combination of those)_(characters/digits
I need a regex pattern to match a sequence of 3 consecutive digits in
I need a regex for the following input: [2 digits], comma, [two digits], comma,
I need to check by Regex expression if 9 or 14 digits are typed.
Can anybody help me with a regex? I have a string with digits like:
I need a regex for four-digit numbers separated by comma (default can also be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.