329 | def replace_string(self, string, search_for, replace_with, count=-1): |
330 | """Replaces ``search_for`` in the given ``string`` with ``replace_with``. |
331 | |
332 | ``search_for`` is used as a literal string. See `Replace String |
333 | Using Regexp` if more powerful pattern matching is needed. |
334 | If you need to just remove a string see `Remove String`. |
335 | |
336 | If the optional argument ``count`` is given, only that many |
337 | occurrences from left are replaced. Negative ``count`` means |
338 | that all occurrences are replaced (default behaviour) and zero |
339 | means that nothing is done. |
340 | |
341 | A modified version of the string is returned and the original |
342 | string is not altered. |
343 | |
344 | Examples: |
345 | | ${str} = | Replace String | Hello, world! | world | tellus | |
346 | | Should Be Equal | ${str} | Hello, tellus! | | | |
347 | | ${str} = | Replace String | Hello, world! | l | ${EMPTY} | count=1 | |
348 | | Should Be Equal | ${str} | Helo, world! | | | |
349 | """ |
350 | count = self._convert_to_integer(count, 'count') |
351 | return string.replace(search_for, replace_with, count) |