{"action":"created","issue":{"url":"https://api.github.com/repos/coala-analyzer/coala/issues/160","labels_url":"https://api.github.com/repos/coala-analyzer/coala/issues/160/labels{/name}","comments_url":"https://api.github.com/repos/coala-analyzer/coala/issues/160/comments","events_url":"https://api.github.com/repos/coala-analyzer/coala/issues/160/events","html_url":"https://github.com/coala-analyzer/coala/issues/160","id":54044277,"number":160,"title":"parsing: escaping/seperating functions contain duplicate code","user":{"login":"sils1297","id":5716520,"avatar_url":"https://avatars.githubusercontent.com/u/5716520?v=3","gravatar_id":"","url":"https://api.github.com/users/sils1297","html_url":"https://github.com/sils1297","followers_url":"https://api.github.com/users/sils1297/followers","following_url":"https://api.github.com/users/sils1297/following{/other_user}","gists_url":"https://api.github.com/users/sils1297/gists{/gist_id}","starred_url":"https://api.github.com/users/sils1297/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sils1297/subscriptions","organizations_url":"https://api.github.com/users/sils1297/orgs","repos_url":"https://api.github.com/users/sils1297/repos","events_url":"https://api.github.com/users/sils1297/events{/privacy}","received_events_url":"https://api.github.com/users/sils1297/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/coala-analyzer/coala/labels/codestyle","name":"codestyle","color":"d4c5f9"},{"url":"https://api.github.com/repos/coala-analyzer/coala/labels/enhancement","name":"enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/coala-analyzer/coala/labels/important","name":"important","color":"e11d21"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/coala-analyzer/coala/milestones/2","html_url":"https://github.com/coala-analyzer/coala/milestones/0.2%20alpha","labels_url":"https://api.github.com/repos/coala-analyzer/coala/milestones/2/labels","id":973255,"number":2,"title":"0.2 alpha","description":"Should make coala about feature complete. This does not yet include 'optional' features like caching which is only performance relevant.","creator":{"login":"sils1297","id":5716520,"avatar_url":"https://avatars.githubusercontent.com/u/5716520?v=3","gravatar_id":"","url":"https://api.github.com/users/sils1297","html_url":"https://github.com/sils1297","followers_url":"https://api.github.com/users/sils1297/followers","following_url":"https://api.github.com/users/sils1297/following{/other_user}","gists_url":"https://api.github.com/users/sils1297/gists{/gist_id}","starred_url":"https://api.github.com/users/sils1297/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sils1297/subscriptions","organizations_url":"https://api.github.com/users/sils1297/orgs","repos_url":"https://api.github.com/users/sils1297/repos","events_url":"https://api.github.com/users/sils1297/events{/privacy}","received_events_url":"https://api.github.com/users/sils1297/received_events","type":"User","site_admin":false},"open_issues":27,"closed_issues":10,"state":"open","created_at":"2015-02-10T09:03:18Z","updated_at":"2015-02-24T20:52:19Z","due_on":"2015-05-30T22:00:00Z","closed_at":null},"comments":14,"created_at":"2015-01-12T11:39:09Z","updated_at":"2015-02-24T22:13:21Z","closed_at":null,"body":""},"comment":{"url":"https://api.github.com/repos/coala-analyzer/coala/issues/comments/75858220","html_url":"https://github.com/coala-analyzer/coala/issues/160#issuecomment-75858220","issue_url":"https://api.github.com/repos/coala-analyzer/coala/issues/160","id":75858220,"user":{"login":"Makman2","id":6023916,"avatar_url":"https://avatars.githubusercontent.com/u/6023916?v=3","gravatar_id":"","url":"https://api.github.com/users/Makman2","html_url":"https://github.com/Makman2","followers_url":"https://api.github.com/users/Makman2/followers","following_url":"https://api.github.com/users/Makman2/following{/other_user}","gists_url":"https://api.github.com/users/Makman2/gists{/gist_id}","starred_url":"https://api.github.com/users/Makman2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Makman2/subscriptions","organizations_url":"https://api.github.com/users/Makman2/orgs","repos_url":"https://api.github.com/users/Makman2/repos","events_url":"https://api.github.com/users/Makman2/events{/privacy}","received_events_url":"https://api.github.com/users/Makman2/received_events","type":"User","site_admin":false},"created_at":"2015-02-24T22:13:21Z","updated_at":"2015-02-24T22:13:21Z","body":"For the second one split could be an option but the begin string and end string shall be at the beginning an end, am I right?\r\nSo for this one just split two times with only one match allowed:\r\n```python\r\nresult = re.split(begin_string, the_text_to_split, 1)\r\ndesired_match = re.split(end_string, result[0], 1)\r\n```\r\nrepeat this until all strings are found surrounded with the begin and end string.\r\nor regex it (I don't know if it's faster, but I think so and it's simpler to use, no code overhead):\r\n```\r\n<begin-string>(.*?)<end-string>\r\n```\r\nAgain use `\\g` and `\\s` flags (to find all matches use like above the `re.findall()` or better `re.finditer()` together with the flag `re.DOTALL`, so newlines are also matched).\r\nThe number of matches can't be easily limited (like I tried), since if you try to use the discrete quantifiers `{n}`, `{m,n}` and so on they don't match every repetition of the preceded expression. Means\r\nthe regex `(a){3}` just matches `a`, but not three times `aaa`.\r\nTo do so I think it's the easiest to use code to rematch, so `re.search()` should be invoked as many times you want feeded with the subsliced string after each match.\r\nTo decide whether to match \\n or not: Just enable/disable the `\\s` flag (`re.DOTALL`).\r\n\r\nAlso note you can use the python regex extension which are quite nice. Especially `(?P<name>)` captures the expression and places the match inside a dictionary with the name *name*.\r\nFor the regexes in python the documentation is quite detailed, but not easy for regex newbies. If you know what you want it's good: https://docs.python.org/2/library/re.html#search-vs-match\r\n\r\nTo test the regexes, I used https://www.regex101.com/#python. Very nice website :+1: \r\n\r\nComing to the last one: What do you mean explicitly with escaping things?"}}