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

The Archive Base Latest Questions

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

Can you tell me the regex for capturing class name from below line: [2011-09-14

  • 0

Can you tell me the regex for capturing class name from below line:

[2011-09-14 20:43:31:943 GMT][E08C17F94E8.http-8080-Processor21]com.abc.MyClass] INFO login successful

Here, I need to capture MyClass.

So far, I was able to capture entire com.abc.MyClass using (?i)^(?:[^\[]*\[){3}

But I couldn’t capture MyClass.

Any help is much appreciated.

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-05-25T16:39:35+00:00Added an answer on May 25, 2026 at 4:39 pm

    If you can assume there are never brackets after that last one, it is pretty simple:

    (\w+)\][^]]$
    

    This captures all of the alphanumeric characters directly preceding the last ] in the string.

    Note: you don’t need to do [^\]] because the spec for PCRE says if the ] is the first in the character list, you don’t need to escape it.

    EDIT: Since you cannot assume no brackets, here is another one that will work:

    \[.+?\]\[.+?\].*?(\w+)\]
    

    This throws away the first two sets of brackets, and grabs the largest chunk of alphanumeric characters before the next bracket. The ? in .+? makes it a non-greedy multiplier, so it will match as few characters as possible, which makes this regex very simple and efficient.

    Nothing against daxnitro, but that regex makes me want to give up programming.

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

Sidebar

Related Questions

Can anyone tell me a regex to preg_replace all timestamps from a log file?
Can somebody please tell me the regex expression to extract EUR/USD from any of
Can someone tell me how to modify this regex to allow periods in a
so from what i can tell, you have to specify artifacts and working directory
As far as I can tell, Scala has definitions for the Enumeration Value class
Can someone tell me the regex pattern to match everything that ends with .log
Can someone tell me what the syntax for a regex would be that would
Can someone tell me the regex pattern to match everything to the right of
Can somebody tell me what regex I would need to filter out ---> %,
I am unfamiliar with Java's regex, can someone tell me how to determine if

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.