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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:56:12+00:00 2026-05-30T16:56:12+00:00

I need to parse the below string, and want to use regular expression but

  • 0

I need to parse the below string, and want to use regular expression but can figure the correct way to do it.

Input Sample (token separator is ; and inside the token is any Char i.e. M/W/D )

1W4;2W35;4M35;13W108

Expected output

List<string> points = new List<string>() {"1W", "2W", "4M", "13W"};
List<int> intervals = new List<int>() {4, 35, 35, 108};

Thanks for any help.

  • 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-30T16:56:14+00:00Added an answer on May 30, 2026 at 4:56 pm

    You could just split your string on tokens by using string.Split and then parse each token using regex:

    var exp = new Regex(@"^(?<point>\d+[a-zA-Z])(?<interval>\d+)$");
    var str = "1W4;2W35;4M35;13W108";
    var tokens = str.Split(new char[] {';'}, StringSplitOptions.RemoveEmptyEntries);
    foreach (var token in tokens)
    {
        var match = exp.Match(token);
        if (match != null)
        {
            points.Add(match.Groups["point"].Value);
            intervals.Add(int.Parse(match.Groups["interval"].Value));
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to parse string that looks like in example below: Regex TitleRegex =
I need to parse and replace text using gsub and a regular expression. A
I need to parse a string like February 12, 1981 as a Date. I
I need to parse a file but the data is in a strange format
I need to parse out the string that has following structure x:{a,b,c,}, y:{d,e,f} etc.
I want to use object instances as modules/functors, more or less as shown below:
In javascript, what is the best way to parse an INT from a string
I have string of format 01-Jan-11 and I need to parse it to a
I'm receiving the below xml response and I need to parse so that all
I need parse through a file and do some processing into it. The file

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.