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

  • Home
  • SEARCH
  • 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 4241008
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T03:14:41+00:00 2026-05-21T03:14:41+00:00

I have two questions. 1: String = xx yy ** I want to remove

  • 0

I have two questions.

1:

String = xx yy **

I want to remove “xx ” so String becomes = “yy *” (xx/yy is fixed and * can be anything)
I tried something like this but it does not work:

string.replaceall("^(xx )$", "");

Isn’t this supposed to replace the first occurence of “xx ” with “” ?

SOLVED(by Lucas)

2:

String = xx yy **

I want to remove ” yy **” so that String becomes = “xx”
I thought something like this, but since the first doesnt work i suspoect this will not too.

string.replaceall("^( yy)*$", "");

UNSOLVED

I actually phrased this one insufficiently,

xx should be **

so xx is not fixed

** yy **
should become ** which is the first **

  • 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-21T03:14:42+00:00Added an answer on May 21, 2026 at 3:14 am

    Try this for the question1:

    string.replaceFirst("^xx ", "");
    

    for the second one:

    string.replaceFirst(" yy .*$", "");
    

    EDIT:
    if regex is not a must, we can use this for the second one:

    string.substring(0, string.indexOf(" yy");
    

    EDIT2: If ‘\n’ will be included in the string, this works for the second one:

    string.replaceFirst(" yy [\\w\\W]*$", "");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been reading other questions and answers around this but I am not
I am aware that this is somewhat a re-post, but I feel like re-posting
None of the answers to two previous questions ( here and here ) resolve
I want to split a string suppressing all null fields Command: ,1,2,,3,4,,.split(',') Result: [,
My adsense ad have a dedicated land page. I want to show the content
I'm continuing to learn C and would like to adhere to whatever is the
I'm writing an app where users enter records. I have a class that represents
Note: I do NOT want to use any framework. The goal is just to
OK let's say I have an array filled with {tube, are, fun} and then
I'm tasked with reading a large text file (around 150 MB), parsing it 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.