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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:26:36+00:00 2026-05-13T20:26:36+00:00

My question is almost identical to an earlier entry I found here but not

  • 0

My question is almost identical to an earlier entry I found here but not quite.

I need to parse through a textfile where the data is structured in this way:
Each item in the file begins with a # followed by the label.
The fields in the post is separated by one or more whitespaces.

Here comes the part I’m having problem with.
Each field may or may not me enclosed by quotation marks, it’s only required if the data contains spaces.

So what I’m after is a regex that splits by whitespace but not if that whitespace is inside a quotation.

At the moment I’m using a separate regex for each label and then but it would be much more efficient to split it immediatly when reading from the file.
As for the account example below (^#[A-z]+)\s([0-9]+)\s(.+)

Example of data

#ACCOUNT 7059 "Misc. travelexpenses"
#ADRESS "M. Jackson" "somewhere over the rainbow" WI53233-1704 555-12345
  • 1 1 Answer
  • 3 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-13T20:26:36+00:00Added an answer on May 13, 2026 at 8:26 pm

    You can use an “OR” construct, to define possible forms of the fields.
    Like

    ([A-z]+|"[^"]+") 
    

    matches both Kring and “Mr. Kring”.

    Edit: So, to get all your fields and the label in the above records you could use

    (?:^#|\s+)([^"#\s]+|"[^"]+")
    

    http://gskinner.com/RegExr/ is a good way to test Regular Expressions.

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

Sidebar

Related Questions

I looked through Stackoverflow and found almost identical question here . It was asked
ok, yesterday I posted almost identical question here , but I wasn't able to
Firstly there is an almost identical question but the answer is not really satisfactory.
My question is almost identical to the one found here: Facebook canvas application never
There is almost identical question , but I have no idea what to do
Sorry - my question is almost identical to this one but since it didn't
I have an almost identical question as How to add code at the entry
My question is almost identical to this one , but the solution there hasn't
I am almost embarrassed to ask this question, but as a long time C
This is almost certainly a very silly question, but for some reason I'm having

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.