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

  • Home
  • SEARCH
  • 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 8561241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:27:33+00:00 2026-06-11T16:27:33+00:00

I have a boatload of text files (see below) that I need to parse.

  • 0

I have a boatload of text files (see below) that I need to parse. They contain chapter information that I’d like to capture and use to create associated records. Report has_many :chapters

Basically I need to read each line and for each BookmarkTitle capture the chapter name (ignoring the CR 
) and then capture the BookmarkPageNumber. Then bundle the pairing up and create a new record with it: report.page.create(title: bookmark_title, page_number: bookmark_page_number)

I’ve played a bit with IO‘s readline but not sure how to capture the contents… a RegEx perhaps? or a more Rails-y way?

sample txt file:

InfoKey: Creator
InfoValue: Adobe Acrobat 9.3.4
InfoKey: Producer
InfoValue: Adobe Acrobat 9.34 Paper Capture Plug-in
InfoKey: ModDate
InfoValue: D:20110315193536-04'00'
InfoKey: CreationDate
InfoValue: D:20110208171413-05'00'
PdfID0: 2dab1ce43882a53cbc24dbb839f921f8
PdfID1: 43b19192e920f38f65de0bf0a2be
NumberOfPages: 258
BookmarkTitle: 1980 Field Service Annual Report
BookmarkLevel: 1
BookmarkPageNumber: 3
BookmarkTitle: TABLE OF CONTENTS
BookmarkLevel: 1
BookmarkPageNumber: 4
BookmarkTitle: LIST OF EXHIBITS
BookmarkLevel: 1
BookmarkPageNumber: 7
BookmarkTitle: I - INTRODUCTION
BookmarkLevel: 1
BookmarkPageNumber: 11
BookmarkTitle: II - EXECUTIVE SUMMARY
BookmarkLevel: 1
BookmarkPageNumber: 16
BookmarkTitle: III - RESULTS AND ANALYSIS OF THE MAINTENANCE USER SURVEY
BookmarkLevel: 1
BookmarkPageNumber: 45
BookmarkTitle: IV - COMPARATIVE ANALYSIS OF BIGCO AND OTHER MAINTENANCE VENDORS
BookmarkLevel: 1
BookmarkPageNumber: 102
BookmarkTitle: V - RESULTS OF VENDOR SURVEY
BookmarkLevel: 1
BookmarkPageNumber: 127
BookmarkTitle: VI - SIGNIFICANT VENDOR ACTIVITIES, 1979-1980
BookmarkLevel: 1
BookmarkPageNumber: 190
BookmarkTitle: APPENDIX A:  DEFINITIONS
BookmarkLevel: 1
BookmarkPageNumber: 199
BookmarkTitle: APPENDIX B:  RESEARCH METHODOLOGY
BookmarkLevel: 1
BookmarkPageNumber: 204
BookmarkTitle: APPENDIX C:  SUPPORTING CHARTS
BookmarkLevel: 1
BookmarkPageNumber: 211
BookmarkTitle: APPENDIX D:  USER QUESTIONNAIRE
BookmarkLevel: 1
BookmarkPageNumber: 222
BookmarkTitle: APPENDIX E:  VENDOR QUESTIONNAIRE
BookmarkLevel: 1
BookmarkPageNumber: 237
  • 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-11T16:27:34+00:00Added an answer on June 11, 2026 at 4:27 pm
    /^BookmarkTitle:\s*(.+?)
\s*BookmarkLevel:\s*(\d+)\s*BookmarkPageNumber:\s*(\d+)\s*$/m
    

    I’m sorry, I’m not a Ruby-On-Rails Developer, but that regular expression will match each bookmark, and return:

    • The entire record
    • The Title (as a sub-match)
    • The Level (as a sub-match)
    • The Page number (as a sub-match)

    It does assume that level and page number are numeric without spaces, comma or decimals. But that could easily by changed.

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

Sidebar

Related Questions

In a boatload of HTML pages, I need to replace all strings like this:
Have a text box which get data for price. If someone enter something like
Have an app that can use tts to read text messages. It can also
Have a procedure which looks like Procedure TestProc(TVar1, TVar2 : variant); Begin TVar1 :=
I have a Ruby on Rails app that needs process many background jobs simultaneously:
Have a form here with bunch of input text fields and a file upload
Have a simple form that has a PictureBox in one location. I want to
Have a chat room, issue is, is that when you submit something, the message
So I have a boat load of pivot tables that I upload everyday to
Have a problem that seems easy on paper but i'm having a big problem

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.