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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T04:58:39+00:00 2026-06-13T04:58:39+00:00

Well I want to call a String newString = oldString.replaceAll(},); but I’m getting error

  • 0

Well I want to call a

String newString = oldString.replaceAll("}","");

but I’m getting error with the } I have tried with:

String newString = oldString.replaceAll("\\}\\","");
String newString = oldString.replaceAll("\}\","");
String newString = oldString.replaceAll("//}//","");
String newString = oldString.replaceAll("/}/","");

and none of them works. How could I do that?

Thanks

Here’s the error:

10-19 12:17:44.907: W/System.err(7030): java.util.regex.PatternSyntaxException: Syntax error in regexp pattern near index 1:
10-19 12:17:44.907: W/System.err(7030): }
10-19 12:17:44.907: W/System.err(7030):  ^
10-19 12:17:44.907: W/System.err(7030):     at java.util.regex.Pattern.compileImpl(Native Method)
10-19 12:17:44.907: W/System.err(7030):     at java.util.regex.Pattern.compile(Pattern.java:400)
10-19 12:17:44.907: W/System.err(7030):     at java.util.regex.Pattern.<init>(Pattern.java:383)
10-19 12:17:44.907: W/System.err(7030):     at java.util.regex.Pattern.compile(Pattern.java:374)
10-19 12:17:44.907: W/System.err(7030):     at java.lang.String.replaceAll(String.java:1784)
10-19 12:17:44.907: W/System.err(7030):     at com.rotaryheart.MainActivity$1.onClick(MainActivity.java:70)
10-19 12:17:44.907: W/System.err(7030):     at android.view.View.performClick(View.java:4084)
10-19 12:17:44.907: W/System.err(7030):     at android.view.View$PerformClick.run(View.java:16966)
10-19 12:17:44.907: W/System.err(7030):     at android.os.Handler.handleCallback(Handler.java:615)
10-19 12:17:44.907: W/System.err(7030):     at android.os.Handler.dispatchMessage(Handler.java:92)
10-19 12:17:44.907: W/System.err(7030):     at android.os.Looper.loop(Looper.java:137)
10-19 12:17:44.907: W/System.err(7030):     at android.app.ActivityThread.main(ActivityThread.java:4940)
10-19 12:17:44.907: W/System.err(7030):     at java.lang.reflect.Method.invokeNative(Native Method)
10-19 12:17:44.907: W/System.err(7030):     at java.lang.reflect.Method.invoke(Method.java:511)
10-19 12:17:44.915: W/System.err(7030):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
10-19 12:17:44.915: W/System.err(7030):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558)
10-19 12:17:44.915: W/System.err(7030):     at dalvik.system.NativeStart.main(Native Method)

and this is the line MainActivity.java 70

String newString = oldString.replaceAll("}","");

Well this is my onClick call

go.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            try {
                try {
                  oldString= "} test } for }";

                        Toast.makeText(getApplicationContext(), "Test for }",
                                Toast.LENGTH_SHORT).show();
                        String newString = oldString.replaceAll("}", "");
                        Toast.makeText(getApplicationContext(), ""+newString , Toast.LENGTH_LONG).show();
                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    });
  • 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-13T04:58:40+00:00Added an answer on June 13, 2026 at 4:58 am

    Well your first code should work fine. You don’t need to escape your }.

    However, you do need to escape opening braces – {, if you are using it.

    So the code: –

    str = str.replaceAll("}", ""); 
    

    works fine. The problem you are getting might be because of something you are hiding from us.

    If you have some other regex than the one shown above, then we can’t see exactly what the problem is.

    Ok, I tried it with your given string: –

       String str = "} test } for }";
       str = str.replaceAll("}", "");
       System.out.println(str);
    

    OUTPUT: –

     test  for 
    

    As you see I am getting the requried output, but can’t understand why this is not working in your code.

    But still, you can try using replace() method, and see if it works: –

    String newString = oldString.replace("}", "");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this javascript modal which I want to use for error reporting. Everything
I have a string! NSString *myString=[NSString stringWithFormat:@This is my lovely string]; What I want
well I want to debug some script with Firebug, (cause I can't see anything
Well I want to render a self closing tag say <img> tag like this
Well this is a simple question i want to filter two elements sorted reverse
Well, i want house image to rotate from -5° to 5° and i wrote
I want to show a welcome screen as well as some basic tutorials of
I want to build an x86 msi package as well as an x64 package
I want to be able to read any well-formed RSS/ATOM file. That would mean
Well, this is what I want to do in my app: I would like

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.