开发者

Jquery Substring Replace

I am building a CMS that uses query strings to show different editors.

Example:

editors.php?editor=Articles

I need to make the word article singular for a button that say "New Article". I want 开发者_Go百科to use the same query string editor value to avoid a big if statement.

I need to do it with javascript. It is only going to run on my 4 pre-defined strings.

basically this: if(string has s at the end){drop the s}


There is no good way to programmatically convert plurals into singulars, or vice versa, in English, because there is no hard and fast rule on how words are pluralized. You need some sort of lookup table--perhaps in the form of if statements, as you suggested. Or maybe you can use a singular word in your URL.


I always go here when I need to emulate a PHP function in javaScript.
And I believe you would want this function.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜