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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:56:15+00:00 2026-06-10T17:56:15+00:00

i know there are tons of posts about sub-stringing, believe me i have searched

  • 0

i know there are tons of posts about sub-stringing, believe me i have searched through many of them looking for an answer to this.

i have many strings, lines from a log, and i am trying to categorize and parse them.

they look something like this:

/long/file/name/with.dots.and.extension:Jan 01 12:00:00 TYPE Static
Message;Dynamic Message

where the filename is the file where the log is located, the date is the date/time that the message was put into the log, and the TYPE is the type of message, and then the message is composed of two parts, a static part and a dynamic part, the static part does not change for the message and the dynamic part can change (obviously) and they are split by a ; but there can be more ; in the dynamic part.

i want to be able to extract the Static Message, and the Dynamic Message.

so far i have been using something like this:

parts = line.split(";")
static = parts[0]
dynamic = ";".join(parts[1:])

not very pretty. and also my static part contains the filename and the date and the type, which i do not want. so then i thought i would do something like this:

parts = " ".join(":".join(line.split(":")[1:]).split(" ")[4:]).split(";")
static = parts[0]
dynamic = ";".join(parts[1:])

which i have tried, and it works to some extent, except sometimes the filename might have a space, or the TYPE might have a space or something isnt working properly and i sometimes get the TYPE as part of the static message… efficiency is an issue since these are thousands of lines of logs which must be parsed and categorized daily. so i am wondering if there is a better way to do this other than this hack-job??

edit: i thought i would provide more examples of lines in the log. to fix what i said earlier, there are a few types of entries.

/long/file/name/with.dots.and.extension:Jan 01 12:00:00 TYPE Static
Message;Dynamic Message

/long/file/name/with.dots.and.extension:Jan 01 12:00:00 MODULE.NAME TYPE THREAD.OR.CONNECTION.INFORMATION Static
Message;Dynamic Message

so as you can see – there are some two types of log entries. those without modules and those with, those with modules can either be connected to connections, and some to threads.
this makes the parsing harder.

  • 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-10T17:56:17+00:00Added an answer on June 10, 2026 at 5:56 pm

    You can limit the split to the first ‘;’ only:

    static, dynamic = line.split(';', 1)
    

    Your static part splitting might take a little more doing, but if you know the number of spaces is going to be static in the first part, perhaps the same trick could work there:

    static = static.split(' ', 4)[-1]
    

    If the first part of the line is more complex (spaces in the TYPE part) I fear that removing everything before that is going to be a more difficult affair. Your best bet is to figure out the limited set of values TYPE could assume and to use a regular expression with that information to split the static part.

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

Sidebar

Related Questions

I know that there are tons of similar questions because I have read them
I know there are tons of threads regarding this issue but I have not
I know there have been many questions on grid and pack in the past
I know there are many discussions about the emulator which is so slow that
I know there are tons of questions about paperclip, but I failed to find
I know there have been tons of answers on this subject, but I still
I know there are tons of blogs, articles, and questions on SO about salting
I know there's tons of threads about this. And I read a few of
Ok so I know there is TONS of documentation online about this, and I
I know that there are tons of articles about this issue. But I'm struggling

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.