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

The Archive Base Latest Questions

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

I have a question involving the Replace Method. I saw a question similar to

  • 0

I have a question involving the Replace Method. I saw a question similar to this on here, but I tried to do the replaceFirst but it didn’t work for me. Is there, any way I can use the replace method to change a string that results in: Helle, Werld; to get it to result to BE “Hello, World” using the replace method. Is there a way using the replaceFirst method for me to search for the sequence of “le” and replace it with “lo” and also change “We” to “Wo”?. Please see my code below:

public class Printer
{

/**Description:  Replacement class
 * 
 * 
 */
public static void main(String[] args) 
{
    String test1Expected = "Hello, World!";


    String newString1;


    String test1 = "Holle, Werld!";

    newString1 = test1.replace('o', 'e');
            //Could I do:  newString1.replaceFirst("le","lo);


    System.out.println("newString1 = " + newString1);
    //Output comes out to "Helle, Werld!"



}

}

  • 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:04:46+00:00Added an answer on June 1, 2026 at 5:04 am

    You can do two regular expressions separatelt one after the other. Please try the following

    newString1 = newString1.replaceAll("le", "lo").replaceAll("We", "Wo");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a question I probably should have asked sooner but didn't in my
This is a conceptual question involving Hadoop/HDFS. Lets say you have a file containing
I have a question involving calling a class's generic method with a type parameter
I have a question today involving the StreamReader class. Specifically initializing this class using
I have checked many of other questions involving issues like this, but none have
Please note that I have seen a similar query here , but think my
A few questions have come up recently involving the Application.Evaluate method callable from Excel
Avoiding Fat Controller So I'm using Zend Framework and I have a question involving
I have an esoteric question involving Python metaclasses. I am creating a Python package
A quick question involving PHP development, I seem to be wondering about this more

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.