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

  • Home
  • SEARCH
  • 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 6237243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:59:30+00:00 2026-05-24T10:59:30+00:00

Inside of a class I have a pattern private Pattern lossWer = Pattern.compile(^\\d+ \\d+

  • 0

Inside of a class I have a pattern private Pattern lossWer = Pattern.compile("^\\d+ \\d+ (\\d+).*"). One of the functions looks like this:

public double[] getWer(){
    double[] wer = new double[someStrings.size()];
    Matcher m;
    for(int i = 0; i < wer.length; i++){
        m = lossWer.matcher(someStrings.get(i));
        wer[i] = Double.parseDouble(m.group(1));
    }
    return wer;
}

Calling this fails with java.lang.IllegalStateException: No match found. When I change it to this, though, it works:

public double[] getWer(){
    double[] wer = new double[someStrings.size()];
    Matcher m;
    for(int i = 0; i < wer.length; i++){
        m = lossWer.matcher(someStrings.get(i));
        if(!m.matches())
            ;
        wer[i] = Double.parseDouble(m.group(1));
    }
    return wer;
}

Of course my application doesn’t just use a blank semi-colon for that line, but I’m illustrating that the line here does nothing but allows the program to proceed without error. Why are lines matched without errors in the second example but not in the first?

  • 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-24T10:59:31+00:00Added an answer on May 24, 2026 at 10:59 am

    You can’t use group() without first calling either find() or matches(). That’s how regexes work. First you create a pattern, then a matcher, then you either find() instances of the regex or check if it matches().

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

Sidebar

Related Questions

I have a class with an NSDictionary attribute. Inside this class I dispatch another
Assume the following: we have class B, which is a private class nested inside
I have this code inside a class that is used by an application and
I have the following dependency property inside a class: class FooHolder { public static
I have a couple of functions inside a class that essentially do the same
Normally when I have a private field inside a class or a struct, I
I have seen member functions programed both inside of the class they belong to
I have a function inside a class that returns a reference to a member
I have an anonymous inner class inside another class ( SomeClass ). Both SomeClass.class.getClasses()
I have a property inside a class that is getting changed by something. The

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.