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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:19:57+00:00 2026-05-23T15:19:57+00:00

Looking for a way to read the following config file sample using a multi

  • 0

Looking for a way to read the following config file sample using a multi line regex matcher. I could just read in the file by line, but I want to get decent with the specifics of flexible regular expression matching.

So the config file is filled with blocks of code as follows:

blockName BLOCK
     IDENTIFIER value
     IDENTIFIER value
     IDENTIFIER
          "string literal value that
          could span multiple lines"

The number of identifiers could be from 1..infinity. IDENTIFIER could be NAME, DESCRIPTION, TYPE, or the like.

I have never worked with multi line regular expressions before. I’m not very familiar with the process. I essentially want to use a findAll function using this regular expression to put all of the parsed block data into a data structure for processing.

EDIT: clarification: I’m only looking to read this file once. I do not care about efficiency or elegance. I want to read the information into a data structure and then spit it out in a different format. It is a large file (3000 lines) and I don’t want to do this by hand.

  • 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-23T15:19:57+00:00Added an answer on May 23, 2026 at 3:19 pm

    Try this, which should work in perl regular expressions:

    ([\w\d]*)\s+BLOCK\s*\n(\s*(NAME|DESCRIPTION|TYPE|...)\s*([\w\d]*|"(.*)")\s*\n)+
    

    I verified it at REGex TESTER using the following test text:

    blockName BLOCK
         NAME value
         NAME value
         DESCRIPTION
              "string literal value that
              could span multiple lines"
    otherName BLOCK
         NAME value
         TYPE value
         DESCRIPTION
              "string literal value that
              could span multiple lines"
    

    It will only find the last block/identifier if the file ends in a newline

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

Sidebar

Related Questions

I am looking for a way to read the following XML <Data> <MaxCount>10</MaxCount> <Points>
I am looking for a way to read an input file and print only
Please note - I am not looking for the right way to open/read a
I am using the jquery-ui-dialog plugin I am looking for way to refresh the
I looking for a way to programmatically start a VOIP call using the SIP
I'm looking for a way to delete a file which is locked by another
I made a config file it has some following format variableName = value variableName
Moving on in my attempt to learn Android, I just read the following :
I'm looking for way to PHP to detect if a script was run from
I looking for a way, specifically in PHP that I will be guaranteed 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.