我正在尝试将变量字符串设置为大写,并将一个字母设置为小写()。字符串将是用户输入的内容,因此提前不知道它将是什么。
用户输入示例输入的内容你好(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