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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:27:25+00:00 2026-05-23T06:27:25+00:00

Hello I want to replace the following chars within a string String a =

  • 0

Hello I want to replace the following chars within a string

String a = "20001=EDTS~^20002=USA~^20003=1170871875~^20004=1~^20005=0~^773=~^665=~^453=2~^448=0A";    
System.out.println(a);
String x  = a.replaceAll("~^", "");
System.out.println(x);

however my output is:

20001=EDTS~^20002=USA~^20003=1170871875~^20004=1~^20005=0~^773=~^665=~^453=2~^448=0A
20001=EDTS~^20002=USA~^20003=1170871875~^20004=1~^20005=0~^773=~^665=~^453=2~^448=0A

So clearly something is up!

I have ran it with the escape chars:

 String x  = fix.replaceAll("\\~^", "\\");

Still the same output. Is there something associated with the ~ I am unaware of?

I must do the same for:

~!~^

~!

all within the same string I figure 3 .replaceAll longest first then the two others. However I cannot get even the simplest to work :S

EDITED: for some reason the got removed

Edit2: it should be replacing the ~^ with a character box that looks similar to []

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

    From what I can tell you don’t need a regular expression at all?

    If no regular expression is required, you can use replace instead of replaceAll which will also replace all occurences but it won’t interpret the first argument as a regular expression (see String.replace)

    String a = "20001=EDTS~^20002=USA~^20003=1170871875~^20004=1~^20005=0~^773=~^665=~^453=2~^448=0A";    
    System.out.println(a);
    String x  = a.replace("~^", "");
    System.out.println(x);
    

    This will output:

    20001=EDTS~^20002=USA~^20003=1170871875~^20004=1~^20005=0~^773=~^665=~^453=2~^448=0A
    20001=EDTS20002=USA20003=117087187520004=120005=0773=665=453=2448=0A
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following string: <SEM>electric</SEM> cu <SEM>hello</SEM> rent <SEM>is<I>love</I>, <PARTITION />mind I want
hello I want replace following phrase: tinymce/jscripts/tiny_mce/plugins/emotions/img/smiley-cool.gif with: http://mysite.com/tinymce/jscripts/tiny_mce/plugins/emotions/img/smiley-cool.gif I have tried : $comments
I want to unescape all nested quotes within a string. The following examples are
I have a long string of some characters. I want to replace some chars
I have the following string: $str = '#hello how are #you and #you and
Say for example I have the following string: var testString = Hello, world; And
I've got a string: $string = Hello World!; I want to turn it into
hi i want to replace all e in a string with - which are
if i have a string like <p>this is some content</p><script>alert('hello');</script> i want to get
hello i have following code and it works fine for finding and replacing string...

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.