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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:07:37+00:00 2026-05-17T19:07:37+00:00

First let me post you some example strings: string_position = (\%s\;\%s\;\%s\;\\;\%s\\r\n\%s\;\%s\;\%s\;\%s – %s\;\%s\;\%.0f\;\FR\;\%.2f\;\%.2f\;\%.2f\;\%s\;\%s\;\%s\;\%s\;\\;\\;\\;\\;\\;\\;\\;\\;\\;\\;\\;\\;\\;\\;\B\\r\n,POSNR_NR_ID,POSNR_NR_ID,POSNR,POSNR_NR_ID,ARTNR_NR_ID,POSNR_NR_ID,CP90NAME,TEXT1,TEXT2,ARTNR_NR_ID,CNT,WIDTH,HEIGHT,DEPTH,INFO1,INFO2,INFO3,INFO4) string_position

  • 0

First let me post you some example strings:

string_position = ("\"%s\";\"%s\";\"%s\";\"\";\"%s\"\r\n\"%s\";\"%s\";\"%s\";\"%s - %s\";\"%s\";\"%.0f\";\"FR\";\"%.2f\";\"%.2f\";\"%.2f\";\"%s\";\"%s\";\"%s\";\"%s\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"B\"\r\n",POSNR_NR_ID,POSNR_NR_ID,POSNR,POSNR_NR_ID,ARTNR_NR_ID,POSNR_NR_ID,CP90NAME,TEXT1,TEXT2,ARTNR_NR_ID,CNT,WIDTH,HEIGHT,DEPTH,INFO1,INFO2,INFO3,INFO4)

string_position = ("STK_PD_BEZ|%s|STK_ID|%s|STK_EBENE|0|ID|%s\r\nSTK_ID|%s|ORDERPOS|%s|STK_EBENE|1|STK_PD_BEZ|%s|STK_FLAENGE|%.2f|STK_FBREITE|%.2f|STK_FDICKE|%.2f|ID|%s|PARENTID|%s\r\n",POSNR,ORDERID,POSNR_NR_ID,ORDERID,POSSTR,CP90NAME,WIDTH,DEPTH,HEIGHT,ARTNR_NR_ID,POSNR_NR_ID)

So I want to parse those strings, but I don’t know how I could start. As I result I want to have two arrays for each string, for example (string 2):

array_a[0] = STK_PD_BEZ|%s;
array_b[0] = POSNR;

array_a[1] = STK_ID|%s;
array_b[1] = ORDERID;

etc…

I hope you understand my problem. I have to find the complementary “variable” to each %s. So the algorithm has to work with any string that looks like the ones I’ve posted.

Thank you 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-17T19:07:38+00:00Added an answer on May 17, 2026 at 7:07 pm

    Just quick implementation, hope it will be useful. I don’t go with regex for this particualr task. I think simple parser will be enough here.

            // const string test = "STK_PD_BEZ|%s|STK_ID|%s|STK_EBENE|0|ID|%s\r\nSTK_ID|%s|ORDERPOS|%s|STK_EBENE|1|STK_PD_BEZ|%s|STK_FLAENGE|%.2f|STK_FBREITE|%.2f|STK_FDICKE|%.2f|ID|%s|PARENTID|%s\r\n,POSNR,ORDERID,POSNR_NR_ID,ORDERID,POSSTR,CP90NAME,WIDTH,DEPTH,HEIGHT,ARTNR_NR_ID,POSNR_NR_ID";
    
            const string test = "\"%s\";\"%s\";\"%s\";\"\";\"%s\"\r\n\"%s\";\"%s\";\"%s\";\"%s - %s\";\"%s\";\"%.0f\";\"FR\";\"%.2f\";\"%.2f\";\"%.2f\";\"%s\";\"%s\";\"%s\";\"%s\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"\";\"B\"\r\n,POSNR_NR_ID,POSNR_NR_ID,POSNR,POSNR_NR_ID,ARTNR_NR_ID,POSNR_NR_ID,CP90NAME,TEXT1,TEXT2,ARTNR_NR_ID,CNT,WIDTH,HEIGHT,DEPTH,INFO1,INFO2,INFO3,INFO4";
    
            // [0] - format string
            // [1..n] - arguments for format
            string[] args = test.Split(',');
    
            // Source parts divided by delimiters. You can extend it.
            string[] parts = args[0].Split("|\r\n;-".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            
            // Format - arg pair
            var parsed = new List<Tuple<string, string>>();
    
            // Current format string
            var format = new List<string>();
            
            // Start from 1 since we skip format string
            int currentValue = 1;
    
            // Building
            foreach (var part in parts)
            {
                if (part.Contains("%"))
                {
                    format.Add(part);
                    parsed.Add(Tuple.Create(string.Join("|", format), args[currentValue++]));
    
                    format.Clear();
                }
                else format.Add(part);
            }
    
            // Printing
            foreach (var pair in parsed)
            {
                Console.WriteLine("{0} = {1}", pair.Item1, pair.Item2);
            }
    
            Console.ReadLine();
    

    Output:

    STK_PD_BEZ|%s = POSNR

    STK_ID|%s = ORDERID

    STK_EBENE|0|ID|%s = POSNR_NR_ID

    STK_ID|%s = ORDERID

    ORDERPOS|%s = POSSTR

    STK_EBENE|1|STK_PD_BEZ|%s = CP90NAME

    STK_FLAENGE|%.2f = WIDTH

    STK_FBREITE|%.2f = DEPTH

    STK_FDICKE|%.2f = HEIGHT

    ID|%s = ARTNR_NR_ID

    PARENTID|%s = POSNR_NR_ID

    Output2:

    "%s" = POSNR_NR_ID

    "%s" = POSNR_NR_ID

    "%s" = POSNR

    ""|"%s" = POSNR_NR_ID

    "%s" = ARTNR_NR_ID

    "%s" = POSNR_NR_ID

    "%s" = CP90NAME

    "%s = TEXT1

    %s" = TEXT2

    "%s" = ARTNR_NR_ID

    "%.0f" = CNT

    "FR"|"%.2f" = WIDTH

    "%.2f" = HEIGHT

    "%.2f" = DEPTH

    "%s" = INFO1

    "%s" = INFO2

    "%s" = INFO3

    "%s" = INFO4


    UPDATE:

    Without formal specification parser’s code will be rather empirical than formally valid. So first of all I would recommend start with making specification for your input then you can easily make parser which would accept all valid strings. For example you can start with Syntax diagrams

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

Sidebar

Related Questions

this is my first post so if you need clarificatrion on anything then just
this is my first post on stackoverflow. Hopefully I am not disturbing anybody... :)
Let me describe the context first: In a .NET C# project, I use NHibernate
Let's say I want to perform a quick HTTP post to a website within
First of all this is not a question about how can I use http
my earlier post pasting over here between the lines; For the creation of a
I have a multi-step form, let's say for the sake of ease it's 2
I am trying to build an android application for a message board. To display
I have a dropdown in my form (the code was provided) and when the

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.