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 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
  • 2 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 a string, something like this: rgb (255, 0, 0) . And I
I have two questions here. How can I show the header of the pop
I have two questions. How can I get the spinner in the figure below
I have two questions. Question1: How can we add a reference to a third-party
I have two questions. I want to send SMSes from a web-site in PHP
Probably a stupid question but so far I can't figure this out... I have
Say I have two user controls and I want to remove an event handler
I have two simple questions about regular expressions. Having the string $10/$50 , I
I just have two questions on Obj-C. I have a string value: 234.67. How
I have two questions regarding component layout using Sencha Touch 2: How can you

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.