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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:29:30+00:00 2026-05-28T01:29:30+00:00

This should be very simple for someone who knows regex. I don’t need anything

  • 0

This should be very simple for someone who knows regex. I don’t need anything hardcore, just a simple altering of .replace(/[e']?s$/, ''); below
Someone else typed this code, it allows for plural endings on the ends of words in my specific situation, so if i typed “planet”, it would also match “planets”, and “planet’s”, but if I typed “hecktus”, it wont match “hecktus”, I think it’s because the word ends with an “s”, and that’s throwing it off. Is there a better way to allow for plural endings for words, that would also allow the word “hecktus” to match “hecktus”?

$.trim(inputWords[i]).replace(/[e']?s$/, '');
  • 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-28T01:29:30+00:00Added an answer on May 28, 2026 at 1:29 am

    Plurals in English are a lot more complicated than that. Even not including irregulars, that code will not really catch a lot. You ran into one case where it fails, but there are going to be more. A single regular expression is not really something you can use to cover what you are thinking about (at least not from the looks of it). And if you are trying to detect if something is plural or singular, you are going have trouble.

    Now, as for what to do with your input. I would recommend stemming things instead (unless you need to use the exact version given for some reason). A Google search prompted a JavaScript Stemming library that is listed on the Porter Stemming Algorithm page here

    Update

    Simple regex that will not match hecktus: /([e']s|[^aiou]s)$/

    In english: Match an s if there is preceeded by an apostrophe, or e. Or match on an s that is proceeded by something other than a, i, o, or u.

    Note that this will also grab the character before in the case of planets, so you can’t just use it in a replace. You can instead do:

    text.replace(/[e']s$/,'').replace(/([^aiou])s/, '$1');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm very poor with regexps but this should be very simple for someone who
This code should be (and is) very simple, and I don't know what I
This should be very simple question. There are many programming languages out there, compiled
This should be very simple, but I'm blocking on this.... Let's say, for the
I feel as if this should be very simple, but it's behaving strangely. I
This should be a very simple procedure of putting a container in the centre
This seems like it should be very simple but I can't get it to
This should be simple, but I am still lost. There is a very similar
This should be very easy but I don't know how to do it. I
This should be simple, very simple, but I'm having a hard time with it.

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.