跳到主要内容
格式化
来源 链接
巴尔马
  • 773.9万
  • 56
  • 532
  • 643

我正在尝试将变量字符串设置为大写,并将一个字母设置为小写()。字符串将是用户输入的内容,因此提前不知道它将是什么。

用户输入示例什么

什么已输入你好(K)什么

你好(K)

什么应为出来你好(k)结果

你好(k)

输入的内容(K) 李尔什么

(K) 李尔

什么是预期结果(k) LEAR公司

(k) LEAR公司

这是我尝试过的,但只有在()位于字符串末尾时才能使其工作。

if(getElementById(“ID”)){var headline=getElementById(“ID”).getValue();var headlineUpper=标题.toUpperCase();var IndexOf=headlineUpper.IndexOf(“(”);if(IndexOf===-1){template.getRegionNode(“区域”).setValue(headlineUpper);}其他{var plus=parseInt(IndexOf+1);var replacement=headlineUpper[plus];var lower=替换.toLowerCase();var render=headlineUpper.replace(headlineUpper.substring(plus),lower+“)”);getElementById(“区域”).setValue(呈现);}}

对我们的系统做,我只能使用vanilla javascript

我正在尝试将变量字符串设置为大写,并将一个字母设置为小写()。字符串将是用户输入的内容,因此提前不知道它将是什么。

用户输入示例什么已输入你好(K)什么应为出来你好(k)

输入的内容(K) 李尔什么是预期结果(k) LEAR公司

这是我尝试过的,但只有在()位于字符串末尾时才能使其工作。

if(getElementById(“ID”)){var headline=getElementById(“ID”).getValue();var headlineUpper=标题.toUpperCase();var IndexOf=headlineUpper.IndexOf(“(”);if(IndexOf===-1){template.getRegionNode(“区域”).setValue(headlineUpper);}其他{var plus=parseInt(IndexOf+1);var replacement=headlineUpper[plus];var lower=替换.toLowerCase();var render=headlineUpper.replace(headlineUpper.substring(plus),lower+“)”);getElementById(“区域”).setValue(呈现);}}

对我们的系统做,我只能使用vanilla javascript

我正在尝试将变量字符串设置为大写,并将一个字母设置为小写()。字符串将是用户输入的内容,因此提前不知道它将是什么。

用户输入示例

什么已输入

你好(K)

什么应为结果

你好(k)

输入的内容

(K) 李尔

什么是预期结果

(k) LEAR公司

这是我尝试过的,但只有在()位于字符串末尾时才能使其工作。

if(getElementById(“ID”)){var headline=getElementById(“ID”).getValue();var headlineUpper=标题.toUpperCase();var IndexOf=headlineUpper.IndexOf(“(”);if(IndexOf===-1){template.getRegionNode(“区域”).setValue(headlineUpper);}其他{var plus=parseInt(IndexOf+1);var replacement=headlineUpper[plus];var lower=替换.toLowerCase();var render=headlineUpper.replace(headlineUpper.substring(plus),lower+“)”);getElementById(“区域”).setValue(呈现);}}

对我们的系统做,我只能使用vanilla javascript

来源 链接

使字符串中的一个字母小写,所有其他字母大写

我正在尝试将变量字符串设置为大写,并将一个字母设置为小写()。字符串将是用户输入的内容,因此提前不知道它将是什么。

用户输入示例输入的内容你好(K)预计会有什么结果你好(k)

输入的内容(K) 李尔预期结果是什么(k) LEAR公司

这是我尝试过的,但只有在()位于字符串末尾时才能使其工作。

if(getElementById(“ID”)){var headline=getElementById(“ID”).getValue();var headlineUpper=标题.toUpperCase();var IndexOf=headlineUpper.IndexOf(“(”);if(IndexOf===-1){template.getRegionNode(“区域”).setValue(headlineUpper);}其他{var plus=parseInt(IndexOf+1);var replacement=headlineUpper[plus];var lower=替换.toLowerCase();var render=headlineUpper.replace(headlineUpper.substring(plus),lower+“)”);getElementById(“区域”).setValue(呈现);}}

对我们的系统做,我只能使用vanilla javascript