5.6 替换字符串中连续出现的指定字符串

题目】:

  给定三个字符串str、from和to,已知from字符串中无重复字符,把str中所有from的子串全部替换成to字符串,对连续出现from的部分要求只替换成一个to字符串,返回最终的结果字符串

  举例:

    str="123abc",from="abc",to="4567",返回"1234567"

    str="123",from="abc",to="456",返回"123"

    str="123abcabc",from="abc",to="X",返回"123X"

猜你喜欢

转载自www.cnblogs.com/latup/p/9974214.html
5.6
今日推荐