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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:48:26+00:00 2026-05-25T16:48:26+00:00

I have a set of strings from a log file that I need to

  • 0

I have a set of strings from a log file that I need to parse:

    timestamp - user not found : user1
    timestamp - exception in xyz.security.plugin: global error : low memory

I want to capture the text between “-” and the last “:”.

Currently I am using r’ -(.*?)\n’ which captures the string till the EOL. Please bear in mind that there may be more than 2 colons used in the string. I need to capture till the very last colon used before EOL.
Also, if there are no “:” colons in the string, it should take EOL as the ending sequence.

thanks.

EDIT: better examples;

    2011-07-29 07:29:44,112 [TP-Processor10] ERROR springsecurity.GrailsDaoImpl  - User not found: sspm
    2011-07-29 09:01:05,850 [TP-Processor3] ERROR transaction.JDBCTransaction  - JDBC commit failed
    2011-07-29 08:32:00,353 [TP-Processor1] ERROR errors.GrailsExceptionResolver  - Exception occurred when processing request: [POST] /webapp/user/index - parameters: runtime exception
  • 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-25T16:48:26+00:00Added an answer on May 25, 2026 at 4:48 pm
    import re
    
    for line in open('logfile.log'):
        match = re.search(r'-(.*):', line)
        if match:
            print match.group(1)
        else:
            match = re.search(r'-(.*)', line)
            if match:
                print match.group(1)
            else:
                print 'No match in line', line.strip()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a set of strings containing characters in a PHP script, I need
I have a set of strings. I would like to extract a regular expression
Abstract Description: I have a set of strings, call it the active set, and
I have a large set of strings. I want to divide the strings into
I have sets of strings in a database. Each set will have less than
I have a numerical indexed array of strings. Another array contains a set of
Okay maybe i just need another set of eyes on this, but I have
I have a Runnable that reads Console output from an externally called exe (see
I need to capture user's X.509 certificates from their cards and map to a
We have a static method in a utility class that will download a file

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.