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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:31:59+00:00 2026-06-06T10:31:59+00:00

How can I remove spaces, a keyword, and everything after it? Here’s what I’m

  • 0

How can I remove spaces, a keyword, and everything after it? Here’s what I’m looking for

var test = $('.replaceMe').attr('title').replace(/ /g, '');

<a class="replaceMe" href="#" title="Replace By Everything After It">haha</a>

resulting in:

test = Replace;

UPDATE:

The keyword is a yet-to-be-determined word that will be included in all titles. In this example, it is “By”.

Both Roko and user1215106’s answers work- in that they remove all the excess from the example, leaving Replace, but I failed to clarify that the phrase before the keyword (in this case, Replace) will vary and will have differing amounts of words.

For example:

title="Replace By Everything After It"

Result= Replace

title="All This Should Stay By Things That Should Go"

Result= AllThisShouldStay
  • 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-06T10:32:01+00:00Added an answer on June 6, 2026 at 10:32 am

    jsFiddle demo

    var keyword = 'By';
    
    var test = $('.replaceMe').attr('title').split(keyword)[0].replace(/ /g, '') ; 
    

    Or instead of having the keyword variable you can do:

    var test = $('.replaceMe').attr('title').split('By')[0].replace(/ /g, '') ; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How we can remove an array entry from : var a = [],b =
I am looking for an API that can remove bundle items added in a
How can I remove all white-spaces from ASP.NET MVC 3 output? UPDATE: I know
How can I remove from a string all characters except white spaces, numbers, and
How can I remove the spaces, tab characters, new line characters between > and
This is my string.. how can i remove the spaces using reg exp in
I need to remove spaces from the end of a string. How can I
How can I strip / remove all spaces of a string in PHP? I
i have been looking through the different questions as to how to remove spaces
how can I remove the space between my video and control bar... I tried

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.