如何在字符串和特定索引中转换特定字符
例如,我有“ alba iuliara”字符串,我想做的是用“ a”转换所有“ a”,但不是第一个和最后一个“ a”。结果必须是“ alba iuliara”,
任何想法如何使用诸如时期,如果和等等的陈述。
For example i have the string "alba iuliara" and what i want to do is to convert all the "a" with "A" but not the first and the last "a". The result must be "albA iuliAra"
Any idea how can i do that using a statement like while, if and etc..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您使用替换方法,这很容易。
代码,如果您不考虑第一个和最后一个字符
It's pretty easy if you use the replace method.
Code if you don't consider the first and last characters
我已经使用了@Jock逻辑,但已修改以使其通用。
I have used @jock logic but modified to make it generic.