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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:58:08+00:00 2026-06-01T15:58:08+00:00

I need a little help for finding regular expression that suits my need, what

  • 0

I need a little help for finding regular expression that suits my need, what I want is that may the input be any string, the regular expression finds any and all integer values and returns them, say

string s1 = "This is some string"
string s2 = " this is 2 string"
string s3 = " this is 03 string"
string s4 = "4 this is the 4th string"
string s5 = "some random string: sakdflajdf;la  989230"
string s6 = "3494309 !@# 234234"

Now what I want is for the regular expression to return,

for s1 = return null (// nothing)
s2 = return 2
s3 = return 0 and 3 (// may separately as 0 and 3 or together as 03 doesn't matter)
s4 = return 4 and 4 (// it has 4 2 times right?)
s5 = 989230 (// may together as this or separately as 9 8 9 2 3 0 again is unimportant, but what's important is that it should return all integer values)
s6 = 3494309 and 234234 (// again may they be together as this or like this 3 4 9 4 3 0 9 and 2 3 4 2 3 4 that is unimportant, all that is imp is that it should return all integers)

I have tried [0-9], \d and ^.*[0-9]+.*$, but none of them seemed to work. Can anyone please help?

ps : please see the updated question at Rename file using regular expression

  • 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-06-01T15:58:10+00:00Added an answer on June 1, 2026 at 3:58 pm

    The regular expression that will match one or more numerals in succession is:

    \d+
    

    You could apply it this way:

    Regex.Matches(myString, @"\d+")
    

    Which will return a collection of MatchCollection object. This will contain the matched values.

    You could use it like so:

    var matches = Regex.Matches(myString, @"\d+");
    
    if (matches.Count == 0)
      return null;
    
    var nums = new List<int>();
    foreach(var match in matches)
    {
      nums.Add(int.Parse(match.Value));
    }
    
    return nums;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need a little help with my jquery here I want all my button with
Need a little help with a regex I'm trying to match a string that
I need a little help creating a catch-all error handling page in my ICEfaces
I need a little help with my .htaccess before I deploy it! I want
need a little help with this one. I have a form that I am
Need a little help with string formatting... I have a string like this: Bmw
Need a little help again. Say I have an unordered list, and I want
I need a little help about a PHP FB app. Matter is that I
I need a little help on finding a tutorial or sample on taking a
I need a little help about the zoomify. I want to display big images,

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.