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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T21:19:39+00:00 2026-06-18T21:19:39+00:00

I have a question related to using regex to pull out data from a

  • 0

I have a question related to using regex to pull out data from a text file. I have a text file in the following format:

REPORTING-OWNER:    

    OWNER DATA: 
        COMPANY CONFORMED NAME:         DOE JOHN
        CENTRAL INDEX KEY:          99999999999

    FILING VALUES:
        FORM TYPE:      4
        SEC ACT:        1934 Act
        SEC FILE NUMBER:    811-00248
        FILM NUMBER:        11530052

    MAIL ADDRESS:   
        STREET 1:       7 ST PAUL STREET
        STREET 2:       STE 1140
        CITY:           BALTIMORE
        STATE:          MD
        ZIP:            21202

ISSUER:     

    COMPANY DATA:   
        COMPANY CONFORMED NAME:         ACME INC
        CENTRAL INDEX KEY:          0000002230
        IRS NUMBER:             134912740
        STATE OF INCORPORATION:         MD
        FISCAL YEAR END:            1231

    BUSINESS ADDRESS:   
        STREET 1:       SEVEN ST PAUL ST STE 1140
        CITY:           BALTIMORE
        STATE:          MD
        ZIP:            21202
        BUSINESS PHONE:     4107525900

    MAIL ADDRESS:   
        STREET 1:       7 ST PAUL STREET SUITE 1140
        CITY:           BALTIMORE
        STATE:          MD
        ZIP:            21202

I want to save the owner’s name (John Doe) and identifier (99999999999) and the company’s name (ACME Inc) and identfier (0000002230) as separate variables. However, as you can see, the variable names (CENTRAL INDEX KEY and COMPANY CONFORMED NAME) are exactly the same for both pieces of information.

I’ve used the following code to extract the owner’s information, but I can’t figure out how to extract the data for the company. (Note: I read the entire text file into $data).

if($data=~m/^\s*CENTRAL\s*INDEX\s*KEY:\s*(\d*)/m){$cik=$1;}
if($data=~m/^\s*COMPANY\s*CONFORMED\s*NAME:\s*(.*$)/m){$name=$1;}

Any idea as to how I can extract the information for both the owner and the company?

Thanks!

  • 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-18T21:19:40+00:00Added an answer on June 18, 2026 at 9:19 pm

    There is a big difference between doing it quick and dirty with regexes (maintenance nightmare), or doing it right.

    As it happens, the file you gave looks very much like YAML.

    use YAML;
    my $data = Load(...);
    say $data->{"REPORTING-OWNER"}->{"OWNER DATA"}->{"COMPANY CONFORMED NAME"};
    say $data->{"ISSUER"}->{"COMPANY DATA"}->{"COMPANY CONFORMED NAME"};
    

    Prints:

    DOE JOHN
    ACME INC
    

    Isn’t that cool? All in a few lines of safe and maintainable code ☺

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

Sidebar

Related Questions

I have been using python with regex to clean up a text file. I
I have a modeling question related to profiles. Firstly, I have looked into using
I have following event class. I have a question related to the Property method
I have a question related to Eclipse PDE development. I'm using target definitions to
I have a question related to invoking functions in a dll file. If I
i have a sepcific question related to using CSS Media Queries. Like when we
I have seen this question and a number of blog posts related to using
I am trying to parse a text file using regex. I am using notepad++
I have question related to bean to json serialziation/deserialization using Jackson. Previously I have
I'm using FitSharp to test an application and have a question related to testing

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.