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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:42:27+00:00 2026-05-15T11:42:27+00:00

Based on my previous question , I’ve come up with a better way to

  • 0

Based on my previous question, I’ve come up with a better way to approach my problem. Here’s what I have in mind:

  1. I want to start extracting word/space characters up to the first occurrence of a pipe (‘|’) delimiter, or else a newline. Trim whitespace at either end. This extraction will be the start of a new “entry”.
  2. For each pipe found (if any), I want to remove the pipe, then extract everything up to the next occurrence of a pipe or newline. Trim whitespace. Everything extracted will be a parameter for above “entry”.
  3. For the next occurrence of a newline:
    1. If the newline begins with a pipe, or the previous line ended with one, I want to remove the newline like it wasn’t there.
    2. Otherwise, I want to begin anew from step 1 with a new “entry”.

Here’s some sample input:

This will be a new entry | param1 |param2  |etc.
This is another entry, but without params
This is a third entry|with a twist
  | I'm using subsequent lines for
  | its parameters.
Yet I still want the next line to be another new entry.

And this should be the output:

Entry #1: "This will be a new entry"
  Params: ["param1","param2","etc."]
Entry #2: "This is another entry, but without params"
Entry #3: "This is a third entry"
  Params: ["with a twist","I'm using subsequent lines for","its parameters."]
Entry #4: "Yet I still want the next line to be another new entry."

What would be a good way to go about doing this?

  • 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-15T11:42:27+00:00Added an answer on May 15, 2026 at 11:42 am

    At this point, you should consider writing a proper grammar and using a parser generator instead of hacking up regexes to do the job.

    Even if you are going for regexes, trying to come up with some miraculous one-liner that does the whole job is going to result in something hideous.

    Instead, consider something like the following psuedocode:

    foreach (line of input)
        If the first non-whitespace character is NOT a delimiter
            output what we have so far, then parse out the title of the next entry
        while there's still text on this line
            grab up to the next delimiter, parse as a parameter.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Based on this previous question How to get ID of calling component in the
Based on this previous question How to get ID of calling component in the
Based on my previous question , in Enterprise Edition Magento it doesn't appear to
My previous question belied my inexperience and was based on an assumption. Now I
Based on answer to my previous question, I would like to ask one more
This question is based off of the same app/source from my previous question which
I posted a previous question about generating a bezier curve based on only the
In the context of this previous question I am wondering if it's possible to
In my previous question I got an excellent answer that helped me detect where
I am not familiar with Hashing algorithms and the risks associated when using them

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.