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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:41:36+00:00 2026-06-09T20:41:36+00:00

I am trying to parse a log file using regex, the problem is as

  • 0

I am trying to parse a log file using regex, the problem is as soon as I turn on SingleLine mode so that I can include multi-line errors then future matches are included in the first match rather than their own.

To explain better, here is an example of a log file:

ERROR 16-08 11:09:59,015 – sdsdfsdfsdfsdfsdf

ERROR 16-08 11:09:59,015 – sdsdfsdfsdfsdfsdf

test

ERROR 16-08 11:09:59,015 – sdsdfsdfsdfsdfsdf

ERROR 16-08 11:09:59,015 – sdsdfsdfsdfsdfsdf

INFO 16-08 11:09:59,015 – sdsdfsdfsdfsdfsdf

test 2

ERROR 16-08 11:09:59,015 – sdsdfsdfsdfsdfsdf

ERROR 16-08 11:09:59,015 – sdsdfsdfsdfsdfsdf

I am using the following regex:

.{5} \d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3} - .+

This matches each line correctly but excludes the part of the message which has run onto a new line. But when I turn on singleline mode there is only one match (the first) and all the other entries are included in it.

Can anyone point me in the right direction?

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-09T20:41:38+00:00Added an answer on June 9, 2026 at 8:41 pm

    Basically the idea behind this solution is to tell your regex not what to include but where to stop.

    This regex uses a positive lookahead to stop nongreedily at the next occurrence of your regex (or at the end of the whole string)

    .{5} \d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3} - .+?
         (?=(.{5} \d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3})|\z)
    

    This includes also the INFO line as part of the previous error message. It sounds a little buggy, so, in case you want to consider the INFO line as a single error message (not part of the previous one) you might consider using this regexp instead

    .{4,5} \d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3} - .+?
    (?=.{4,5} \d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3})
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to parse a log file that looks like this: %%%% 09-May-2009 04:10:29
I am trying to parse a rather long log file and creating a better
I'm trying to use python to parse a log file and match 4 pieces
I'm trying to parse a file from the web on Android using the DOM
I am trying to parse a log file of test results with the following
I've been trying to parse the phpunit json log using jquery however it returns
I am using a test .json file and can console.log the url fine in
I'm trying to write a regex that will parse out the directory and filename
I am trying to parse an icalendar file (.ics) using ical4j library, and its
I'm trying to learn how to parse an xml file using SAX parser in

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.