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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:58:05+00:00 2026-06-14T23:58:05+00:00

I need to be able to extract values from a string like the one

  • 0

I need to be able to extract values from a string like the one below, and assign them to specific variables.

[1;1HSVC_LVL={89} CALLS_OFF={966} CALLS_Q={2} CURR_DEL={67}[K[2;1HACD_HOLD={4} AN_WAIT={3} NRDY_WRAP={9} WALK_AWAY={14} FRCD_OFF={12}[K[4;1H{EOM}[K

The actual string is somewhat longer, and contains about 16 key/value pairs. It can also contain extraneous characters as shown above. This string will be arriving every few seconds, and I need to parse the values out to variables fairly quickly each time. I’ll have a seperate variable for each key/value pair.

Within the string, I need to search for the key name, ie ‘SVC_LVL’ and assign the key value (contained within ‘{}’ ie ’89’ for key name ‘SVC_LVL’) to a variable. The values will not necessarily be the same length each time, so I cant simply strip a specific number of chars from the string, need to pull the value within ‘{}’

So what I’m really looking for is a way to find each specific key name (which I do know in advance), then pull the value from within the next ‘{}’ after it, assign that to a value, and proceed to the next one.

Not sure if regex is the best way to be doing that, and what would be an example for pulling each one out seperately. Is doing that 16 times a sensible thing? or should I be looking at a different way?

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-06-14T23:58:06+00:00Added an answer on June 14, 2026 at 11:58 pm

    Use this if you want to search for a specific key:

    string key = "SVC_LVL";
    string pattern = key + @"\=\{(?<value>[^\}]+)\}";
    foreach (Match m in Regex.Matches(input, pattern))
    {
        Console.WriteLine(m.Groups["value"].Value);
    }
    

    Or use this to list all key-value pairs:

    string patAllKeyValues = @"(?<key>[\p{L}_]+)\=\{(?<value>[^\}]+)\}";
    foreach (Match m in Regex.Matches(input, patAllKeyValues))
    {
        Console.WriteLine("{0} -> {1}", 
                           m.Groups["key"].Value, 
                           m.Groups["value"].Value);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I occasionally need to extract specific rows from a data.frame based on values from
I need to extract images from a FB fan page. I'm able to read
I have a labels that need values retreieved from a Database. I am able
I need to be able to extract the different between two hex colours, represented
What I need is to be able to extract the files in a .rar
I need to be able to strip out a condition in a string, here
I'm trying to extract values from the following statement using Regex , the statement
I'm connecting to a database using pyodbc and need to extract information from certain
Users of the website need to able to store images in their area ,
Need to be able to pull Magento products into an external template. Need to

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.