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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T02:53:17+00:00 2026-05-20T02:53:17+00:00

I am having a problem with the following bit of code. I am trying

  • 0

I am having a problem with the following bit of code. I am trying to match a string. When I have a match everything works perfectly. When it does not find a match it throws an exception and causes a force close.


Code Snippet

private void validatePhoneNumberFormat(String t){
    Pattern p = Pattern.compile("^Match this exactly!$");
    Matcher m = p.matcher(t);
        m.find();
    if (m.group(0) != ""){
        this.myString = m.group(0);
        this.setIsValid(true);
        this.setStatus(0);
    } else {
        this.myString = "Invalid Input String";
        this.setIsValid(false);
        this.setStatus(99); //  String parsing error
    }
}

LogCat

02-17 14:12:10.562: WARN/dalvikvm(3854): threadid=1: thread exiting with uncaught exception (group=0x40015560)
02-17 14:12:11.322: ERROR/AndroidRuntime(3854): FATAL EXCEPTION: main
02-17 14:12:11.322: ERROR/AndroidRuntime(3854): java.lang.IllegalStateException: No successful match so far
02-17 14:12:11.322: ERROR/AndroidRuntime(3854):     at java.util.regex.Matcher.ensureMatch(Matcher.java:607)
02-17 14:12:11.322: ERROR/AndroidRuntime(3854):     at java.util.regex.Matcher.group(Matcher.java:358)
02-17 14:12:11.322: ERROR/AndroidRuntime(3854):     at com.android.example.RegExTest.MyList.validateMyStringFormat(MyList.java:47)
02-17 14:12:11.322: ERROR/AndroidRuntime(3854):     at com.android.example.RegExTest.MyList.<init>(MyList.java:15)
02-17 14:12:11.322: ERROR/AndroidRuntime(3854):     at com.android.example.RegExTest.DataManagerActivity.readInputFile(DataManagerActivity.java:128)
02-17 14:12:11.322: ERROR/AndroidRuntime(3854):     at com.android.example.RegExTest.DataManagerActivity$2.onClick(DataManagerActivity.java:77)
02-17 14:12:11.322: ERROR/AndroidRuntime(3854):     at android.view.View.performClick(View.java:2485)
02-17 14:12:11.322: ERROR/AndroidRuntime(3854):     at android.view.View$PerformClick.run(View.java:9080)
02-17 14:12:11.322: ERROR/AndroidRuntime(3854):     at android.os.Handler.handleCallback(Handler.java:587)
02-17 14:12:11.322: ERROR/AndroidRuntime(3854):     at android.os.Handler.dispatchMessage(Handler.java:92)
02-17 14:12:11.322: ERROR/AndroidRuntime(3854):     at android.os.Looper.loop(Looper.java:123)
02-17 14:12:11.322: ERROR/AndroidRuntime(3854):     at android.app.ActivityThread.main(ActivityThread.java:3647)
02-17 14:12:11.322: ERROR/AndroidRuntime(3854):     at java.lang.reflect.Method.invokeNative(Native Method)
02-17 14:12:11.322: ERROR/AndroidRuntime(3854):     at java.lang.reflect.Method.invoke(Method.java:507)
02-17 14:12:11.322: ERROR/AndroidRuntime(3854):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
02-17 14:12:11.322: ERROR/AndroidRuntime(3854):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
02-17 14:12:11.322: ERROR/AndroidRuntime(3854):     at dalvik.system.NativeStart.main(Native Method)
02-17 14:12:11.402: WARN/ActivityManager(62):   Force finishing activity com.android.example.RegExTest/.DataManagerActivity
  • 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-20T02:53:18+00:00Added an answer on May 20, 2026 at 2:53 am

    Try checking for a match instead:

    if (m.matches()){
    

    instead of:

    if (m.group(0) != ""){
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a bit of a problem with the following code. I've seen tons
I'm having a bit of a problem using FieldOffset correctly with arrays. The code
I'm having a bit of a problem. I'm using FireFox 3.6 and have the
Having a bit of a problem here on a matrix multiplication code. I seem
I'm having a bit of problem with casting and datagrids. I have a LINQ
I'm having the following problem: cannot convert from 'MyProject.DataLayerServiceRef.MyDTO' to 'WCFService.MyDTO' when i'm trying
I'm having the following problem: I have a ListView and I get the layout
I'm having problem in the following line: rd.PrintOptions.PaperSize = PaperSize.PaperFanfoldStdGerman; it throws an exception
I'm having the following problem. I created a application context file for spring.net. The
I'm having a little problem with the following: When I execute this line: echo

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.