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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:05:59+00:00 2026-05-29T22:05:59+00:00

Lorem ipsum dolor sit amet consectetur adipisicing elit. Is it possible to use .replace

  • 0
Lorem ipsum dolor sit amet consectetur adipisicing elit.

Is it possible to use .replace to change everything beyond amet in the sentence above?

  • 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-29T22:06:03+00:00Added an answer on May 29, 2026 at 10:06 pm

    It is.

    str.replace(/(amet).+$/, '$1FOO')
    

    If "amet" actually contains weird characters, you have to ‘regex quote’ them: ., -, [ etc.

    EDIT
    Explaining regex is hard.

    • (amet) => Capture a literal “amet”. Capture, because you want to keep that part for the replacement, because you want to replace everything after “amet”.
    • .+ => Any type of characters (.), but at least one (+). If you want at least 0, you can use * instead of +.
    • $ => the end of the subject (str). In thise case, it’s unnecessary, because regex is greedy and won’t stop until you tell it to (and since .+ will never stop matching, the end is the end)
    • $1 => This is a placeholder for ‘the first match’. In this case, it’s awlways "amet", because we matched a literal "amet". If the regex is variable, this $1 will be unknown (which is what it exists for).
    • FOO => Another literal (the replacement). Your question includes “… change everything after …” which – in my eyes – means “replace by "FOO"“.

    Clear enough? If not, I’d be happy to try to explain better. Always a great resource (for young and old, wise and not-so-wise and pro’s and beginners): http://www.regular-expressions.info/

    To conclude: regex is AWESOME.

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

Sidebar

Related Questions

the target text is something like: Lorem ipsum dolor #sit# amet, consectetur #adipisicing# elit,
Supposing I have the following text: Lorem ipsum dolor sit amet, consectetur adipisicing elit,
Here's the input HTML: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
Given two collections: srcCollection := #('Lorem' 'ipsum' 'dolor' 'sit' 'amet,' 'consectetur' 'adipisicing' 'elit,' 'sed'
Given the following HTML: <p> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed
For example, in this text: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc
I have this The body: <body><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent
For instance, if I have a TextBlock: Lorem ipsum dolor sit amet, consectetur adipisicing
I have the following piece of HTML: <div><p>Lorem ipsum dolor sit amet, consectetur adipisicing
I have an ordered list <ol> <li class=odd>Lorem ipsum dolor sit amet, consectetur ...</li>

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.