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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:13:43+00:00 2026-06-01T05:13:43+00:00

for (Entry<String, String> entry : map.entrySet()) { String delimiter = **; result = result.replace(delimiter

  • 0
   for (Entry<String, String> entry : map.entrySet()) {

                String delimiter = "**";
                result = result.replace(delimiter + entry.getKey() + delimiter, entry.getValue());

            }

result is my string to be replaced by hashmap values.
Here string (result variable) is returning as itself not replacing any value.
Please any one have suggestions ?


From comment

My hashmap contains,

HashMap<String, String> map = new HashMap<String, String>(); 
map.put("Rid", serviceBooking.getId().toString()); 
map.put("Rname", customer.getName()); 
map.put("Rnic", "");
  • 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-01T05:13:45+00:00Added an answer on June 1, 2026 at 5:13 am

    The algorithm OK Here’s a working, executable example:

    // sample input
    String input = "abcd **Rid** efgh";
    
    // a small map
    Map<String, String> map = new HashMap<String, String>();
    map.put("Rid","VALUE");
    
    // the loop that replaces the **Rid** substring
    for (Map.Entry<String,String> entry:map.entrySet()){
      input = input.replace("**"+entry.getKey()+"**", entry.getValue());
      System.out.println(input);
    }
    

    It prints

    abcd VALUE efgh
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Map testMap = new HashMap(); for(Map.Entry<String, Object> entry:testMap.entrySet()){ } it has error tip:Type mismatch:
Set<String> tempSet = new HashSet<String>(); for (Map.Entry<String, String> entry : map.entrySet()) { String orginalKeys
Map<String, String[]> map = request.getParameterMap(); for (Entry<String, String[]> entry : map.entrySet()) { String name
String delimiter = \\*\\*; String html = <html><head></head><body>**USERNAME** AND **PASSWORD**</body></html>; Map<String, String> mp =
I get error in following lines. error: incompatible types required : java.util.Map.entry<java.lang.String,java.lang.String[]> found :java.lang.Object
I have a NSMutableDictionary of NSMutableSets. Each set entry is a string, something like
In VS2008, you could enable right-margin marks by creating a string registry entry named
I put a string array elements is a map where elements of string array
Im reading values from a file and storing these values in a hashmap, using
I have this HashMap: HashMap<String, Integer> m which basically stores any word (String) and

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.