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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:11:03+00:00 2026-05-26T06:11:03+00:00

Hi I was recently developing a code where i had to extract the last

  • 0

Hi I was recently developing a code where i had to extract the last 3 group of digits. So i used pattern to extract the data. But i failed to understand. CAN any one help me to understand it ??

    String str ="EGLA 0F 020";
    String def = "ALT 1F 001 TO ALT 1F 029";
    String arr[] = def.split("TO");
    String str2 = arr[0];
    System.out.println("str2:"+str2);
    Pattern pt = Pattern.compile("[0-9][0-9][0-9]$");
    Matcher m1 = pt.matcher(str);
    Matcher m2 = pt.matcher(str2);
    boolean flag = m1.find();
    boolean flag2 = m2.find();
    if(flag)
        System.out.println("first match:::"+m1.group(0));
    else 
        System.out.println("Not found");
    if(flag2)
        System.out.println("first match:::"+m2.group(0));
    else
        System.out.println("Not found");

The output produced for the above code is As follows:::

    str2:ALT 1F 001 
    first match:::020
    Not found

Please Do reply iam stuck here ??

  • 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-26T06:11:04+00:00Added an answer on May 26, 2026 at 6:11 am

    It’s because when you split you have a trailing space.

    String str = "EGLA 0F 020";
    String str2 = "ALT 1F 001 ";
    //                       ^ trailing space
    

    You could fix it a number of ways. For example:

    • by splitting on " TO "
    • trimming the result
    • allowing trailing spaces in your regular expression.

    For example, this change would work:

    String arr[] = def.split(" TO ");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im developing an app with MinGW and Code::Blocks and i recently updated the MinGW
I've had the thrill recently of developing web service applications. Most of my experience
I've been developing a couple of C# tools recently, but primarily working with a
I recently had the following problem: I'm developing a numerical library in Python (called
I have started developing a webpage and recently hired someone to write code to
I have had good experiences recently developing with ASP.NET MVC and am considering whether
Recently, I have been developing a practice of making many things in my code
I have just recently discovered how much I enjoy developing code the TDD way:
I've been developing a few jQuery widgets recently but 2 things have been bothering
So I am just beginning recently developing some simple apps for the iphone. I

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.