| 4095 | } |
| 4096 | |
| 4097 | String String::replace(const String& p_key, const String& p_with) const |
| 4098 | { |
| 4099 | String new_string; |
| 4100 | int search_from = 0; |
| 4101 | int result = 0; |
| 4102 | |
| 4103 | while ((result = find(p_key, search_from)) >= 0) |
| 4104 | { |
| 4105 | new_string += substr(search_from, result - search_from); |
| 4106 | new_string += p_with; |
| 4107 | search_from = result + p_key.length(); |
| 4108 | } |
| 4109 | |
| 4110 | if (search_from == 0) |
| 4111 | { |
| 4112 | return *this; |
| 4113 | } |
| 4114 | |
| 4115 | new_string += substr(search_from, length() - search_from); |
| 4116 | |
| 4117 | return new_string; |
| 4118 | } |
| 4119 | |
| 4120 | String String::replace(const char* p_key, const char* p_with) const |
| 4121 | { |
no test coverage detected