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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:18:48+00:00 2026-06-17T09:18:48+00:00

during my coding I’ve come across a problem that involved parsing a string like

  • 0

during my coding I’ve come across a problem that involved parsing a string like this:

{15} there are 194 red balloons, {26} there are 23 stickers, {40} there are 12 jacks, ….

my code involved pulling both the sentence and the number into two separate arrays.
I’ve solved the problem involving parsing out the sentence into its own array using a *.Remove(0, 5) to eliminate the first part the problem with that part was that I had to make sure that the file always was written to a standard where {##} where involved however it was not as elegant as I would like in that some times the number would be {3} and i would be forced to make it { 3}.

as there were also the chance of the string containing other numbers I wasn’t able to simply parse out the integers first.

int?[] array = y.Split(',')
            .Select(z =>
            {
                int value;
                return int.TryParse(z, out value) ? value : (int?)null;
            })
            .ToArray();

so anyway back to the problem at hand, I need to be able to parse out “{##}” into an array with each having its own element.

  • 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-17T09:18:49+00:00Added an answer on June 17, 2026 at 9:18 am

    Here’s one way to do it using positive lookaheads/lookbehinds:

    string s = "{15} there are 194 red balloons, {26} there are 23 stickers, {40} there are 12 jacks";
    
    // Match all digits preceded by "{" and followed by "}"
    int[] matches = Regex.Matches(s, @"(?<={)\d+(?=})")
        .Cast<Match>()
        .Select(m => int.Parse(m.Value))
        .ToArray(); 
    
    // Yields [15, 26, 40]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

During this year there will be coming couple sub-600€ multi-touch portable computers that contain
I came across a confusing fact during coding a script. How can i find
Most of the time during coding, i found that whether i can write code
I'm coding a JTable that is capable of handling frequent updates. Typically this JTable
During coding I frequently encounter this situation: I have several objects ( ConcreteType1 ,
During coding in Visual Studio I got an unresolved external symbol error and I've
I am coding SQL Server 2005 trigger. I want to make some logging during
I'm learning iOS having come from Android. In Android there is a special assets
One of the things about programming is that there are several ways to achieve
Is there any way to force firing of valueChangeListener during typing into an component?

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.