How does one allow a search for a plural keyword s to return the singular as well

How does one allow a search for a plural keyword s to return the singular as well

thetailwindthetailwind Posts: 2Questions: 1Answers: 0
edited May 2017 in Free community support

Using bSmart column filtering, how does one allow a search for a plural keyword to return the singular as well? Lets assume only keywords that are pluralized by the letter s on the end.

Here is the codeblock I am looking at:

if ( bSmart )
            {
                /* Generate the regular expression to use. Something along the lines of:
                 * ^(?=.*?\bone\b)(?=.*?\btwo\b)(?=.*?\bthree\b).*$
                 */
                asSearch = bRegex ? sSearch.split( ' ' ) : _fnEscapeRegex( sSearch ).split( ' ' );
                sRegExpString = '^(?=.*?'+asSearch.join( ')(?=.*?' )+').*$';
                return new RegExp( sRegExpString, bCaseInsensitive ? "i" : "" );
            }

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 64,756Questions: 1Answers: 10,715 Site admin
    Answer ✓

    There is currently no option for that I'm afraid. Your best bet would probably be to just remove the plural from the submitted search word(s) and search on that only.

    You'd need to consider non-trivial plurals as well, such as es as well. Probably not too bad if you are only handling English language, but a nightmare if you are doing a multi-lingual interface.

    Allan

  • thetailwindthetailwind Posts: 2Questions: 1Answers: 0

    Hey Allan. First time posting, thanks for your fast reply.

This discussion has been closed.