We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JS自带的replace中只能替换所有符合的字符,但是我想有一个可以替换指定位置的字符,就是只修改指定位置的那一个。
replaceInposition
这个是用JS实现的简单案例: let myString = "hello"; let indexToReplace = 1; // 字符串中第二个字符,即索引值为 1 myString = myString.substring(0, indexToReplace) + "a" + myString.substring(indexToReplace + 1); console.log(myString); // 输出 "hallo"
The text was updated successfully, but these errors were encountered:
No branches or pull requests
这个需求解决了什么问题:
JS自带的replace中只能替换所有符合的字符,但是我想有一个可以替换指定位置的字符,就是只修改指定位置的那一个。
建议的 API 是什么样的:
replaceInposition
是否已有其他不错的替代方案:
这个是用JS实现的简单案例:
let myString = "hello";
let indexToReplace = 1; // 字符串中第二个字符,即索引值为 1
myString = myString.substring(0, indexToReplace) + "a" + myString.substring(indexToReplace + 1);
console.log(myString); // 输出 "hallo"
The text was updated successfully, but these errors were encountered: