{"action":"opened","issue":{"url":"https://api.github.com/repos/CausalityLtd/ponyc/issues/225","labels_url":"https://api.github.com/repos/CausalityLtd/ponyc/issues/225/labels{/name}","comments_url":"https://api.github.com/repos/CausalityLtd/ponyc/issues/225/comments","events_url":"https://api.github.com/repos/CausalityLtd/ponyc/issues/225/events","html_url":"https://github.com/CausalityLtd/ponyc/issues/225","id":83483105,"number":225,"title":"'fun replace' in string.pony","user":{"login":"jkleiser","id":107986,"avatar_url":"https://avatars.githubusercontent.com/u/107986?v=3","gravatar_id":"","url":"https://api.github.com/users/jkleiser","html_url":"https://github.com/jkleiser","followers_url":"https://api.github.com/users/jkleiser/followers","following_url":"https://api.github.com/users/jkleiser/following{/other_user}","gists_url":"https://api.github.com/users/jkleiser/gists{/gist_id}","starred_url":"https://api.github.com/users/jkleiser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkleiser/subscriptions","organizations_url":"https://api.github.com/users/jkleiser/orgs","repos_url":"https://api.github.com/users/jkleiser/repos","events_url":"https://api.github.com/users/jkleiser/events{/privacy}","received_events_url":"https://api.github.com/users/jkleiser/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-06-01T13:05:53Z","updated_at":"2015-06-01T13:05:53Z","closed_at":null,"body":"I think a function like the one below (except the use of 'src') could be useful in builtin/string.pony:\r\n```\r\n  fun replace(src: String, olds: String, news: String): String =>\r\n    var res = src\r\n    var offset: I64 = src.size().i64()\r\n    try\r\n      while offset > 0 do\r\n        offset = res.rfind(olds, offset)\r\n        res = if offset > 0 then res.substring(0, offset - 1) + news else news end +\r\n          res.substring(offset + olds.size().i64(), -1)\r\n      end\r\n    end\r\n    res\r\n```\r\n"}}