{"action":"created","issue":{"url":"https://api.github.com/repos/cfengine/core/issues/2316","labels_url":"https://api.github.com/repos/cfengine/core/issues/2316/labels{/name}","comments_url":"https://api.github.com/repos/cfengine/core/issues/2316/comments","events_url":"https://api.github.com/repos/cfengine/core/issues/2316/events","html_url":"https://github.com/cfengine/core/pull/2316","id":105669675,"number":2316,"title":"Redmine#7346: implement regex_replace","user":{"login":"tzz","id":67764,"avatar_url":"https://avatars.githubusercontent.com/u/67764?v=3","gravatar_id":"","url":"https://api.github.com/users/tzz","html_url":"https://github.com/tzz","followers_url":"https://api.github.com/users/tzz/followers","following_url":"https://api.github.com/users/tzz/following{/other_user}","gists_url":"https://api.github.com/users/tzz/gists{/gist_id}","starred_url":"https://api.github.com/users/tzz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tzz/subscriptions","organizations_url":"https://api.github.com/users/tzz/orgs","repos_url":"https://api.github.com/users/tzz/repos","events_url":"https://api.github.com/users/tzz/events{/privacy}","received_events_url":"https://api.github.com/users/tzz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"jimis","id":3584514,"avatar_url":"https://avatars.githubusercontent.com/u/3584514?v=3","gravatar_id":"","url":"https://api.github.com/users/jimis","html_url":"https://github.com/jimis","followers_url":"https://api.github.com/users/jimis/followers","following_url":"https://api.github.com/users/jimis/following{/other_user}","gists_url":"https://api.github.com/users/jimis/gists{/gist_id}","starred_url":"https://api.github.com/users/jimis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimis/subscriptions","organizations_url":"https://api.github.com/users/jimis/orgs","repos_url":"https://api.github.com/users/jimis/repos","events_url":"https://api.github.com/users/jimis/events{/privacy}","received_events_url":"https://api.github.com/users/jimis/received_events","type":"User","site_admin":false},"milestone":null,"comments":12,"created_at":"2015-09-09T19:38:33Z","updated_at":"2015-10-29T11:10:25Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/cfengine/core/pulls/2316","html_url":"https://github.com/cfengine/core/pull/2316","diff_url":"https://github.com/cfengine/core/pull/2316.diff","patch_url":"https://github.com/cfengine/core/pull/2316.patch"},"body":"See https://dev.cfengine.com/issues/7346\r\n\r\nImplements `regex_replace` with no external dependencies.\r\n\r\nExample:\r\n\r\n```\r\nbundle agent main\r\n{\r\n  vars:\r\n      \"test\" string => \"abcdefghij\";\r\n      \"void\" string => regex_replace(\"\", $(test), \"\", \"g\");\r\n      \"void1\" string => regex_replace(\".\", $(test), \"\", \"g\");\r\n      \"void2\" string => regex_replace(\"\", $(test), \"x\", \"g\");\r\n      \"allofitwithTEST\" string => regex_replace(\".*\", $(test), \"TEST\", \"\");\r\n      \"nomatch\" string => regex_replace(\"nonesuch\", $(test), \"TEST\", \"g\");\r\n      \"dots_everywhere\" string => regex_replace(\".\", $(test), \"-DOT-\", \"g\");\r\n      \"cap123\" string => regex_replace(\"(...)\", $(test), \"[cap=$1]\", \"g\");\r\n      \"simple_nocase\" string => regex_replace(\"ABC\", $(test), \"ABC\", \"gi\"); # case-insensitive\r\n      \"simple\" string => regex_replace(\"abc\", $(test), \"ABC\", \"g\");\r\n\r\n  methods:\r\n      \"\" usebundle => expected();\r\n      \"\" usebundle => report();\r\n}\r\n\r\nbundle agent expected\r\n{\r\n  vars:\r\n      \"void\" string => $(main.test);\r\n      \"void1\" string => \"\";\r\n      \"void2\" string => \"xaxbxcxdxexfxgxhxixjx\";\r\n      \"allofitwithTEST\" string => \"TEST\";\r\n      \"nomatch\" string => $(main.test);\r\n      \"dots_everywhere\" string => \"-DOT--DOT--DOT--DOT--DOT--DOT--DOT--DOT--DOT-\";\r\n      \"cap123\" string => \"[cap=abc][cap=def][cap=ghi]j\";\r\n      \"simple\" string => \"ABCdefghij\";\r\n      \"simple_nocase\" string => \"ABCdefghij\";\r\n\r\n  methods:\r\n      \"\" usebundle => report();\r\n}\r\n\r\nbundle agent report\r\n{\r\n  vars:\r\n      \"state\" data => bundlestate(\"main\");\r\n      \"state_string\" string => storejson(state);\r\n\r\n      \"expected\" data => bundlestate(\"expected\");\r\n      \"expected_string\" string => storejson(expected);\r\n\r\n  reports:\r\n      \"ACTUAL: $(state_string)\";\r\n      \"EXPECTED: $(expected_string)\";\r\n}\r\n```\r\n\r\noutput:\r\n\r\n```\r\nR: ACTUAL: {\r\n  \"allofitwithTEST\": \"TEST\",\r\n  \"cap123\": \"[cap=abc][cap=def][cap=ghi]j\",\r\n  \"dots_everywhere\": \"-DOT--DOT--DOT--DOT--DOT--DOT--DOT--DOT--DOT--DOT-\",\r\n  \"nomatch\": \"abcdefghij\",\r\n  \"simple\": \"ABCdefghij\",\r\n  \"simple_nocase\": \"ABCdefghij\",\r\n  \"test\": \"abcdefghij\",\r\n  \"void\": \"abcdefghij\",\r\n  \"void1\": \"\",\r\n  \"void2\": \"xaxbxcxdxexfxgxhxixjx\"\r\n}\r\nR: EXPECTED: {\r\n  \"allofitwithTEST\": \"TEST\",\r\n  \"cap123\": \"[cap=abc][cap=def][cap=ghi]j\",\r\n  \"dots_everywhere\": \"-DOT--DOT--DOT--DOT--DOT--DOT--DOT--DOT--DOT-\",\r\n  \"nomatch\": \"abcdefghij\",\r\n  \"simple\": \"ABCdefghij\",\r\n  \"simple_nocase\": \"ABCdefghij\",\r\n  \"void\": \"abcdefghij\",\r\n  \"void1\": \"\",\r\n  \"void2\": \"xaxbxcxdxexfxgxhxixjx\"\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/cfengine/core/issues/comments/152148629","html_url":"https://github.com/cfengine/core/pull/2316#issuecomment-152148629","issue_url":"https://api.github.com/repos/cfengine/core/issues/2316","id":152148629,"user":{"login":"jimis","id":3584514,"avatar_url":"https://avatars.githubusercontent.com/u/3584514?v=3","gravatar_id":"","url":"https://api.github.com/users/jimis","html_url":"https://github.com/jimis","followers_url":"https://api.github.com/users/jimis/followers","following_url":"https://api.github.com/users/jimis/following{/other_user}","gists_url":"https://api.github.com/users/jimis/gists{/gist_id}","starred_url":"https://api.github.com/users/jimis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jimis/subscriptions","organizations_url":"https://api.github.com/users/jimis/orgs","repos_url":"https://api.github.com/users/jimis/repos","events_url":"https://api.github.com/users/jimis/events{/privacy}","received_events_url":"https://api.github.com/users/jimis/received_events","type":"User","site_admin":false},"created_at":"2015-10-29T11:10:25Z","updated_at":"2015-10-29T11:10:25Z","body":"> Could you please do this as a followup commit? If you prefer I do it, I won't be able to do it until the weekend. Sorry, I'm just booked solid.\r\n\r\nAllright, I'll try to steal some time!"}}