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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:19:19+00:00 2026-06-04T23:19:19+00:00

I need to recognise the server events from a log file.I am using patter

  • 0

I need to recognise the server events from a log file.I am using patter matching for the purpose. My regex is not working . Please check wether my regex is wrong or problem is some wher else.

Sample input is :–

2009/12/14 11:49:20.55                  00 STARTUP  Distributed Access Infrastructure V1.1.0   
2009/12/14 11:49:20.55                  01 STARTUP    Tools Access Server initialization started   
2009/12/14 11:49:20.55 TAS#####EC05003E 00 STARTUP  Environment:    
2009/12/14 11:49:20.55 TAS#####EC05003E 01 STARTUP    Job.....DAITAS     System...EC05      ASID.....003E    
2009/12/14 11:49:20.55 TAS#####EC05003E 02 STARTUP    User....USRT001    Group....SYS1      JobNum...STC00079
2009/12/14 11:49:20.55 TAS#####EC05003E 03 STARTUP    Local...GMT-08     GMT......2009/12/14 19:49

My script is:

public void map(Object key, Text value, Context context) throws IOException , InterruptedException{

        String input=value.toString();
        String delimiter= "[\n]";
        String[] tokens=input.split(delimiter);
        String sample = null;

        Pattern pattern;
        String regex= " \\s+\\d+\\s+[a-z,A-Z]+\\s ";
        pattern=Pattern.compile(regex);




        for(int i=0;i<tokens.length;i++){
            sample=tokens[i];
            System.out.println(sample.toString());
            System.out.println("enter here");

            Matcher match=pattern.matcher(sample);
            boolean val = match.matches();

            System.out.println("the conditions" + val);
            System.out.println("enter here 2");
            if(val){
                System.out.println("the regex is found" + val);
                logEvent.set(sample);
                System.out.println("the value of logEvent is "+ logEvent);
            }
            else{
                logInformation.set(sample);
                System.out.println("the log informaTION" + logInformation);
            }
        context.write(logEvent, logInformation);    

I need to recognise — Startup

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-04T23:19:21+00:00Added an answer on June 4, 2026 at 11:19 pm

    Try this

    try {
        Regex regexObj = new Regex(@"(?im)\s+(?<event>\d+\s+[a-z]+)\s+(?<details>[^\r\n]+)$");
        Match matchResults = regexObj.Match(subjectString);
        while (matchResults.Success) {
            for (int i = 1; i < matchResults.Groups.Count; i++) {
                Group groupObj = matchResults.Groups[i];
                if (groupObj.Success) {
                    // matched text: groupObj.Value
                    // match start: groupObj.Index
                    // match length: groupObj.Length
                } 
            }
            matchResults = matchResults.NextMatch();
        } 
    } catch (ArgumentException ex) {
        // Syntax error in the regular expression
    }
    

    RegEx explanation

    @"
    (?im)          # Match the remainder of the regex with the options: case insensitive (i); ^ and $ match at line breaks (m)
    \s             # Match a single character that is a “whitespace character” (spaces, tabs, and line breaks)
       +              # Between one and unlimited times, as many times as possible, giving back as needed (greedy)
    (?<event>      # Match the regular expression below and capture its match into backreference with name “event”
       \d             # Match a single digit 0..9
          +              # Between one and unlimited times, as many times as possible, giving back as needed (greedy)
       \s             # Match a single character that is a “whitespace character” (spaces, tabs, and line breaks)
          +              # Between one and unlimited times, as many times as possible, giving back as needed (greedy)
       [a-z]          # Match a single character in the range between “a” and “z”
          +              # Between one and unlimited times, as many times as possible, giving back as needed (greedy)
    )
    \s             # Match a single character that is a “whitespace character” (spaces, tabs, and line breaks)
       +              # Between one and unlimited times, as many times as possible, giving back as needed (greedy)
    (?<details>    # Match the regular expression below and capture its match into backreference with name “details”
       [^\r\n]        # Match a single character NOT present in the list below
                         # A carriage return character
                         # A line feed character
          +              # Between one and unlimited times, as many times as possible, giving back as needed (greedy)
    )
    $              # Assert position at the end of a line (at the end of the string or before a line break character)
    "
    

    Hope this helps.

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

Sidebar

Related Questions

I have been working on a prototype site using a mamp server and the
i am getting web data from .net web server using NSMutableUrl request. i am
I am working on a on-screen keyboard for Android, and I need to recognize
Need some help, please. I have a line of horizontal thumbnails loaded as ONE
i need to check for a specific DateTime value in my table from my
I need to perform a complex import in a Microsoft SQL Server 2000. Since
It's not code-related but IDE related. I'm working on a .NET solution with about
I need to install older version of mysql server on mac os, but I
I have some WSDL from which I need to generate a web service implementation.
I need a way to include an external XML file in PHP which does

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.