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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:26:12+00:00 2026-06-15T05:26:12+00:00

This may have been asked somewhere else – unfortunately it’s quite a difficult thing

  • 0

This may have been asked somewhere else – unfortunately it’s quite a difficult thing to google for.

Regularly when programming I find myself with constructs of the form (I’m looking particularly for a Java answer, but I’d be fascinated by a general solution)

String a = getStringFromPlace();
a=processStringInSomeWay(a);
sendStringToSomePlace(a); 

My problem is that processStringInSomeWay(a) breaks if given some particular character, “£”, say, and so I end up writing this…

String a = getStringFromPlace();
a=a.replace("£","replacevalue");
a=processStringInSomeWay(a);
a=a.replace("replacevalue","£");
sendStringToSomePlace(a); 

but this, of course, breaks if ‘replacevalue’ happens to be in the input. I could just choose a ridiculous value of ‘replacevalue’ but that’s clearly not good practice. What is the best practice in this situation?

EDIT – this is in the particualar case where one does not have control over the ‘processStringInSomeWay()’ method. And I’m also interested in the situation were a has to be processed as one unit, it can’t be split.

  • 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-15T05:26:13+00:00Added an answer on June 15, 2026 at 5:26 am

    Your question is quite generic in the sense that without knowing what you need to do with these strings is almost impossible to give one precise answer.

    Solutions I see are:

    • remove directly the characters that the method shouldn’t process (eg replaceAll("£","") )
    • change the processing method to skip character with are not handled in current version
    • split strings whenever an unwanted character is found and process them separately
    • just place an escape sequence that is always the same for every symbol that is unmanaged (eg replaceAll("£",escape+"£") )

    This problem is common in many situations and from what I saw you usually end up by just deciding that you have a sequence which can’t be used naturally because it’s used as an escape sequence. This is true in compression protocols, network protocols and in many other cases.

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

Sidebar

Related Questions

This question may have been asked already - but unfortunately, I could not find
This may already have been asked, but StackOverflow is massive and trying to google
This question may have been asked before, but I had trouble finding an answer,
This has / may have been asked before, but, as far as I remember,
this question may have been asked many times, but could not find any suitable
This question may have been asked before, but I'm starting to get into game
This may have been asked already, but I can't find it, so here goes.
This may have been asked before, and I have seen similar solutions... Perhaps I
This may have been asked in the past but I couldnt find a suitable
This question may have been asked before and I'm sorry if I missed it,

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.