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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:07:48+00:00 2026-06-06T03:07:48+00:00

I have the following node(s) which I retrieve in a streamreader. There could be

  • 0

I have the following node(s) which I retrieve in a streamreader. There could be numerous of these. I am only interested to retrieve a few groups within this node for instance REPLICATE_ID, ASSAY_NUMBER,FEW DATES FIELDS.

The ordering of the fields within the node could be different and sometimes new fields could be present as well but the fields I want to extract they will not change.

So far the regex I have matches the entire node so in case the node has new fields or the order is different, it breaks. Is it possible to match groups I am only interested in?

   TEST_REPLICATE
    {
        REPLICATE_ID            453w
        ASSAY_NUMBER            334
        ASSAY_VERSION           4
        ASSAY_STATUS            test
        DILUTION_ID         1
        SAMPLE_ID           "NC_dede"
        SAMPLE_TYPE         Specimen
        TEST_ORDER_DATE         05.23.2012
        TEST_ORDER_TIME         04:25:07
        TEST_INITIATION_DATE        05.23.2012
        TEST_INITIATION_TIME        05:19:43
        TEST_COMPLETION_DATE        05.23.2012
        TEST_COMPLETION_TIME        05:48:01
        ASSAY_CALIBRATION_DATE      NA
        ASSAY_CALIBRATION_TIME      NA
        TRACK           1
        PROCESSING_LANE     1
        MODULE_SN       "EP004"
        LOAD_LIST_NAME          C:\BwedwQwedw_SCC\edwLoadlist2RACKSB.json
        OPERATOR_ID         "Q_dwe"
        DARK_SUBREADS           16 23 19 20 16 18 21 16 17 18 19 19 20 22 19 20 19 20 18 20 17 20 21 16 19 23 20 22 19 20
        SIGNAL_SUBREADS         18 17 20 21 42 61 41 31 30 30 26 26 25 22 24        DARK_COUNT          577
        SIGNAL_COUNT            781
        CORRECTED_COUNT         204
        STD_BAK             1.95965044971226
        AVG_BAK             19.2333333333333
        STD_FOR             8.67212471810898
        AVG_FOR             26.0333333333333
        SHAPE               NA
        EXCEPTION_STRING        TestException - Parameters:Unable to process test, background read failure.
        RESULT              NA
        REPORTED_RESULT         NA
        REPORTED_RESULT_UNITS       NA
        REAGENT_MASTER_LOT      13600LI02
        REAGENT_SERIAL_NUMBER       25022
        RESULT_FLAGS            RUO
        RESULT_INTERPRETATION       NA
        DILUTION_PROTOCOL       UNDILUTED
        RESULT_COMMENT          frer 1 LANE A
        DATA_MANAGEMENT_FIELD_1     NA
        DATA_MANAGEMENT_FIELD_2     NA
        DATA_MANAGEMENT_FIELD_3     NA
        DATA_MANAGEMENT_FIELD_4     NA
    }

    string pat = @"TEST_REPLICATE\s*{\s*REPLICATE_ID\s*([^}]*?)\s+ASSAY_NUMBER\s*([^}]*?)\s+ASSAY_VERSION\s*([^}]*?)\s+DILUTION_ID\s*([^}]*?)\s+SAMPLE_ID\s*([^}]*?)\s+SAMPLE_TYPE\s*([^}]*?)\s+TEST_ORDER_DATE\s*([^}]*?)\s+TEST_ORDER_TIME\s*([^}]*?)\s+TEST_INITIATION_DATE\s*([^}]*?)\s+TEST_INITIATION_TIME\s*([^}]*?)\s+TEST_COMPLETION_DATE\s*([^}]*?)\s+TEST_COMPLETION_TIME\s*([^}]*?)\s+ASSAY_CALIBRATION_DATE\s*([^}]*?)\s+ASSAY_CALIBRATION_TIME\s*([^}]*?)\s+TRACK\s*([^}]*?)\s+PROCESSING_LANE\s*([^}]*?)\s+MODULE_SN\s*([^}]*?)\s+LOAD_LIST_NAME\s*([^}]*?)\s+OPERATOR_ID\s*([^}]*?)\s+DARK_SUBREADS\s*([^}]*?)\s+SIGNAL_SUBREADS\s*([^}]*?)\s+DARK_COUNT\s*([^}]*?)\s+SIGNAL_COUNT\s*([^}]*?)\s+CORRECTED_COUNT\s*([^}]*?)\s+STD_BAK\s*([^}]*?)\s+AVG_BAK\s*([^}]*?)\s+STD_FOR\s*([^}]*?)\s+AVG_FOR\s*([^}]*?)\s+SHAPE\s*([^}]*?)\s+EXCEPTION_STRING\s*([^}]*?)\s+RESULT\s*([^}]*?)\s+REPORTED_RESULT\s*([^}]*?)\s+REPORTED_RESULT_UNITS\s*([^}]*?)\s+REAGENT_MASTER_LOT\s*([^}]*?)\s+REAGENT_SERIAL_NUMBER\s*([^}]*?)\s+RESULT_FLAGS\s*([^}]*?)\s+RESULT_INTERPRETATION\s*([^}]*?)\s+DILUTION_PROTOCOL\s*([^}]*?)\s+RESULT_COMMENT\s*([^}]*?)\s+DATA_MANAGEMENT_FIELD_1\s*([^}]*?)\s+DATA_MANAGEMENT_FIELD_2\s*([^}]*?)\s+DATA_MANAGEMENT_FIELD_3\s*([^}]*?)\s+DATA_MANAGEMENT_FIELD_4\s*([^}]*?)\s*}";   
  • 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-06T03:07:49+00:00Added an answer on June 6, 2026 at 3:07 am

    Yeah, you probably should just parse the record for key-value pairs.

    Here is a code sample if you want to extract key-value pairs from a record.
    When a match is found, the key’s your looking for can be tested against those in the capture collection.

    You can also alter the regex as to how the begin/end of record are allowed.
    But don’t alter the core, it protects from catastrophic backtracking.

    Regex alternatives:

    # Record starts on a new line, closing brace can be anywhere
    
    ^ [^\S\n]*TEST_REPLICATE\s*\{
     (?>
          \s* (?<key> [^\s{}]+ ) [^\S\n]* (?<val> [^\n{}]*? ) [^\S\n]* (?:$|(?=\}))
     )*
     \s*\}
    
    
    # Record starts anywhere, closing brace is on a new line 
    
    TEST_REPLICATE\s*\{
     (?>
          \s* (?<key> [^\s{}]+ ) [^\S\n]* (?<val> [^\n{}]*? ) [^\S\n]* $
     )*
     \s*\}
    

    C# test code:

    Regex testRx = new Regex(
     @"
      ^ [^\S\n]* TEST_REPLICATE     # Record, starts on a newline
        \s*                         # Optional whitespaces (trims blank lines)
        \{                          # Record opening brace
          (?>                           # Atomic group
             \s*                           # Optional many whitespace (trims blank lines)
             # Line in record to be recorded
             (?<key> [^\s{}]+)                # required <key>, not whitespacs nor braces
             [^\S\n]*                         # trim whitespaces (don't include newline)
             (?<val> [^\n{}]*?)               # optional <value>, not newlines nor braces
             [^\S\n]*                         # trim whitespaces (don't include newline)
             (?:$|(?=\}))                   # End of line, or next char is a closing brace
          )*                            # End atomic group, do many times (optional)
        \s*                         # Optional whitespaces (trims blank lines)
      \}                            # Record closing brace
     ", RegexOptions.IgnorePatternWhitespace | RegexOptions.Multiline);
    
    string testdata = @"
     TEST_REPLICATE{}
     TEST_REPLICATE{
         REPLICATE_ID            1asdf985
         ASSAY_NUMBER            123sdg
         ASSAY_VERSION           4sdgn
         ASSAY_TYPE            unknown
     }
    
     TEST_REPLICATE
     {
         REPLICATE_ID            
         ASSAY_NUMBER            123    
         ASSAY_VERSION           4   
         ASSAY_TYPE            unknown   
         DILUTION_ID         1
         SAMPLE_ID           ""NC_HIV1""
         SAMPLE_TYPE         Specimen
         TEST_ORDER_DATE         05.21.2012
         TEST_ORDER_TIME         03:44:01
         TEST_INITIATION_DATE        05.21.2012
         TEST_INITIATION_TIME        04:03:36
    
     TEST_COMPLETION_DATE        05.21.2012
     TEST_COMPLETION_TIME        04:29:32
         ASSAY_CALIBRATION_DATE              NA
         ASSAY_CALIBRATION_TIME      NA
         TRACK           1
         PROCESSING_LANE     1
         MODULE_SN       ""EP004""
         LOAD_LIST_NAME          C:\sdddd
         OPERATOR_ID         ""Q_SI""
         DARK_SUBREADS           NA
         SIGNAL_SUBREADS         NA
         DARK_COUNT          NA
         SIGNAL_COUNT            NA
         CORRECTED_COUNT         NA
         STD_BAK             NA
         AVG_BAK             NA
         STD_FOR             NA
         AVG_FOR             NA
         SHAPE               NA
         EXCEPTION_STRING        Test execution was stopped.
         RESULT              NA
         REPORTED_RESULT         NA
         REPORTED_RESULT_UNITS       NA
         REAGENT_MASTER_LOT      2345
         REAGENT_SERIAL_NUMBER       25022
         RESULT_FLAGS            NA
         RESULT_INTERPRETATION       NA
         DILUTION_PROTOCOL       UNDILUTED
         RESULT_COMMENT          HIV NC 1
         DATA_MANAGEMENT_FIELD_1     NA
         DATA_MANAGEMENT_FIELD_2     NA
         DATA_MANAGEMENT_FIELD_3     NA
         DATA_MANAGEMENT_FIELD_4     NA
     }
        ";
    
    Match m_testrec = testRx.Match(testdata);
    
    // Each match contains a single record
    //
    while (m_testrec.Success)
    {
        Console.WriteLine("New Record\n------------------------");
    
        CaptureCollection cc_key = m_testrec.Groups["key"].Captures;
        CaptureCollection cc_val = m_testrec.Groups["val"].Captures;
    
        for (int i = 0; i < cc_key.Count; i++)
        {
            Console.WriteLine("'{0}' = '{1}'", cc_key[i].Value, cc_val[i].Value);                                                                                                 
            // 
            // Test specific keys here
            //  if (cc_key[i].Value == "REAGENT_SERIAL_NUMBER") ...
    
        }
        Console.WriteLine("------------------------");
    
        // Get next record
        m_testrec = m_testrec.NextMatch();
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a network protocol In which I have following requirement each node
In my XML file I have a node which is there per layer node
I have following xml and I want to fetch the value of node which
I'm newbie to Neo4j/GraphDB and have created following simple graph node[1]user1 which is 'friend'
I have the following selector, which works: parent::node()/myNS:expField[myNS:Nam='NAMETOFIND']/myNS:Val What I want is to do
I have the following node.js server-side code: var app = require('http').createServer(handler) , io =
I have the following express node.js app. It's using the 'redis' npm package. app.get(/test,function(req,res){
On my node.js server I have the following code: //Generate a token var token
I have the following to execute shell commands using Node: function puts( error, stdout,
I have the following Schemas in Mongoose/Node.js: var ItemsSchema = new Schema({ itemname: String,

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.