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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:49:28+00:00 2026-06-05T02:49:28+00:00

I am new to regular expression, please kindly help me on the error scenario

  • 0

I am new to regular expression, please kindly help me on the error scenario where I need to use regex to match two error messages (appearing in different lines, but same paragraph) in AND condition from a log file:

Msg1 - ERROR [com.company.util.ejb.TimedBean] () FAILED processing Loader

Msg2 - java.lang.RuntimeException: Message code:[SL] is unknown.

Basically, what I need is to match (msg1)&&(msg2), in this case, (ERROR…Loader) will appear in the first line and (java…unknown) will follow in the next line. The messages will always follow this order. I am not programming in any typical language here, they will be put into a enterprise tool that accepts regexp.

If possible, would you also show me how to make it in Or condition as (msg1)||(msg2)?

  • 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-05T02:49:29+00:00Added an answer on June 5, 2026 at 2:49 am

    Matching two consecutive lines is, in theory, just a matter of putting the two regular expressions end-to-end. So for purposes of illustration, let’s say you’ve got a file named logfile.txt that contains messages you’re looking for. Then from a Linux command line you could do something like this:

    pcregrep -M -o '^ERROR\N*Loader$\njava\N*unknown\.$\n' logfile.txt
    

    and it would print the line pairs that you’re looking for. Breaking it down into parts:

    • ^ERROR matches the word ERROR at the beginning of a line.
    • \N* matches any number of characters that aren’t a line terminator.
    • Loader$ matches the word Loader at the end of a line.
    • \n matches the newline character. (Might be different on Windows.)
    • java\N*unknown\.$\n is more of the same.

    BUT… And this is a big problem… The tool that handles your regular expression must be capable of doing multi-line matches, and that capability must be turned on. (That’s what the -M command line option to pcregrep enables.) Many regexp tools, such as plain grep on many systems, can’t do multiline searches. So you may be out of luck.

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

Sidebar

Related Questions

I need help creating a regular expression for redirecting my old URL's to new
help me please with regular expression in ruby. I have a text like 1.
I have a regular expression as: Regex regExpForPurchaseIndent = new System.Text.RegularExpressions.Regex(^(([0-9]*[a-zA-Z]*)*[, ]*)*$;); The string
I have this regular expression in c#: Regex oRegex_ = new Regex(<!-- #BeginEditable \Body\[^>]*>(.*)<!--
I'm pretty new to regular expression. Just tried to analyse a BB-Code that could
I'm new to regular expression and just can't seem to figure this out: '/^[A-Za-z0-9](?:.[A-Za-z0-9]+)$/'
What would be regular Expression for validating Date format like mm/yyyy. I am new
I'm new to php and am trying to write a regular expression using preg_match
How can I set any quantity of new lines with a regular expression? $var
I'm new to regular expressions, but I'd like to match a string up to

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.