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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:35:09+00:00 2026-05-11T18:35:09+00:00

errorString=AxisFault\n faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException\n faultSubcode: \n faultString: My Error\n faultActor: \n faultNode: \n faultDetail: \n

  • 0
errorString="AxisFault\n
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException\n
 faultSubcode: \n
 faultString: My Error\n
 faultActor: \n
 faultNode: \n
 faultDetail: \n
    {}string: this is the fault detail"


Pattern pattern = Pattern.compile(".*faultString(.*)", Pattern.DOTALL);
Matcher matcher = pattern.matcher(errorString);
if (matcher.matches()) {
   String match = matcher.group(1);
   return match;
}

I want to get “My Error”, but it returns to the end of the whole string instead of matching to the \n at the end of the faultString line. I’ve tried many techniques to get it to stop at the end of the line, without success.

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-05-11T18:35:09+00:00Added an answer on May 11, 2026 at 6:35 pm

    You shouldn’t be passing Pattern.DOTALL; that causes newlines to be matched by .*, which is exactly what you don’t want here.

    A better regex would be:

    Pattern pattern = Pattern.compile("faultString: (.*)");
    

    and then, instead of matcher.matches(), use find() to see if it appears anywhere in the string.

    Note also that I’ve modified the regex to only group the “My Error” part, instead of “: My Error” like your original one would have.

    Just to be clear, here is the code I tested:

    Pattern pattern = Pattern.compile("faultString: (.*)");
    Matcher matcher = pattern.matcher(errorString);
    if (matcher.find()) {
        System.out.println(matcher.group(1));
    }
    

    where errorString is the same as yours.
    The output is:

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

Sidebar

Related Questions

I'm getting an error msg DataReader.h:13: error: 'String' was not declared in this scope
Consider the following code: std::string my_error_string = Some error message; // ... throw std::runtime_error(std::string(Error:
Take the method System.Windows.Forms.Control.Invoke(Delegate method) Why does this give a compile time error: string
I get this error with reCaptcha: 'Input error: response: Required field must not be
FMOD_RESULT result; FMOD::System *system; result = FMOD::System_Create(&system); if (result != FMOD_OK) { printf(FMOD error!
I'm connecting to a web server from my android application via HttpsUrlConnection or HttpUrlConnection
I'm trying to upload a .avi file to an FTP server with QFtp: void
//error string date string s = 2012-4-5-02; DateTime dt; if (DateTime.TryParse(s,out dt)) MessageBox.Show(dt.ToString(yyyy-MM-dd)); else
Error on the following GridView xml Multiple annotations found at this line: - error:
I'm receiving this error String was not recognized as a valid DateTime with 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.