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 6095445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:48:46+00:00 2026-05-23T12:48:46+00:00

hi I found on the Internet that this regexp accept positive number ^\d+$ and

  • 0

hi I found on the Internet that this regexp accept positive number ^\d+$ and this accept nothing ^$
So no I wanna combine this two regexp but with no success. I try this (^\d+$)|(^$) but this didnt work. So help me with regexp which accept positive integer and nothing
thx a lot

  • 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-23T12:48:46+00:00Added an answer on May 23, 2026 at 12:48 pm

    Simply do:

    ^\d*$
    

    The * means: “zero or more times”.

    Since you’ve asked most questions with the Java tag, I’m assuming you’re looking for a Java solution. Note that inside a string literal, the \ needs to be escaped!

    A demo:

    class Test {
      public static void main(String[] args) {
        String[] tests = {"-100", "", "2334", "0"};
        for(String t : tests) {
          System.out.println(t + " -> " + t.matches("\\d*"));
        }
      }
    }
    

    produces:

    -100 -> false
     -> true
    2334 -> true
    0 -> true
    

    Note that matches(...) already validates the entire input string, so there’s no need to “anchor” it with ^ and $.

    Beware that it would also return true for numbers that exceed Integer.MAX_VALUE and Long.MAX_VALUE. SO even if matches(...) returned true, parseInt(...) or parseLong(...) may throw an exception!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found some mapkit code on the internet that looks like this: - (void)recenterMap
I have found this line of MatLab code on the internet that displays a
I found this code on internet that compares a normal distribution to different student
According to the information in the internet I found out that two following variables
I have searched through internet & found that there are no any direct method
This is some code I found on the internet. I'm not sure how it
I have little question. I found this on internet: Type t = typeof(MyClass); MethodInfo[]
I found this code in the internet and I modified it for my use,
I'm writing an application with GWT and I found on the internet that there's
I am using some code I found on the internet that creates a countdown

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.