Jump to content

Recommended Posts

in this instance the last character.

 

Please be specific. Are you wanting to remove the letter "s" in any string where the word "clubs" exists? Are you wanting to remove the last letter from a string? Are you wanting to remove the letter "s" from any string?

 

Give some details as to what you are trying to accomplish - exactly. substr() would be one possible solution based upon certain parameters. In others it may be inefficient or not even appropriate to use.

Where "string" is the string variable:

string.replace(/clubs$/i, 'club');

 

That will change "clubs" or "Clubs" (or any case variations, i.e. it is case insensitive) to "club" if those matches occur at the very end of the string.

 

If you maintain the case of the word, someone else might have a simple replace() solution. I could do it, but would take a few more lines of code using a match() and then rebuilding the string. If you need to maintiain case, please state so.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.