{"action":"created","issue":{"url":"https://api.github.com/repos/pocoproject/poco/issues/643","labels_url":"https://api.github.com/repos/pocoproject/poco/issues/643/labels{/name}","comments_url":"https://api.github.com/repos/pocoproject/poco/issues/643/comments","events_url":"https://api.github.com/repos/pocoproject/poco/issues/643/events","html_url":"https://github.com/pocoproject/poco/issues/643","id":52241625,"number":643,"title":"Regex: match all","user":{"login":"DEvil0000","id":3344302,"avatar_url":"https://avatars.githubusercontent.com/u/3344302?v=3","gravatar_id":"","url":"https://api.github.com/users/DEvil0000","html_url":"https://github.com/DEvil0000","followers_url":"https://api.github.com/users/DEvil0000/followers","following_url":"https://api.github.com/users/DEvil0000/following{/other_user}","gists_url":"https://api.github.com/users/DEvil0000/gists{/gist_id}","starred_url":"https://api.github.com/users/DEvil0000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DEvil0000/subscriptions","organizations_url":"https://api.github.com/users/DEvil0000/orgs","repos_url":"https://api.github.com/users/DEvil0000/repos","events_url":"https://api.github.com/users/DEvil0000/events{/privacy}","received_events_url":"https://api.github.com/users/DEvil0000/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/pocoproject/poco/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2014-12-17T13:48:34Z","updated_at":"2015-04-02T15:52:38Z","closed_at":null,"body":"i would suggest a enhancement for regex.\r\nif you extract parts of a string with capturing groups you can only get the first or last group matches.\r\ni would suggest a method like matchall() or support for /g option (i think this is the global option) to find all matches of a regex in a string.\r\n\r\nexample:\r\nhttps://regex101.com/\r\nphp regex\r\nregex: /abc(\\d)/g\r\nstring to match: abc1xyzabc2xyzabc3\r\nexpected result:\r\nmatches=3\r\nmatch1: \"1\"\r\nmatch2: \"2\"\r\nmatch3: \"3\""},"comment":{"url":"https://api.github.com/repos/pocoproject/poco/issues/comments/88955042","html_url":"https://github.com/pocoproject/poco/issues/643#issuecomment-88955042","issue_url":"https://api.github.com/repos/pocoproject/poco/issues/643","id":88955042,"user":{"login":"martin-osborne","id":8464143,"avatar_url":"https://avatars.githubusercontent.com/u/8464143?v=3","gravatar_id":"","url":"https://api.github.com/users/martin-osborne","html_url":"https://github.com/martin-osborne","followers_url":"https://api.github.com/users/martin-osborne/followers","following_url":"https://api.github.com/users/martin-osborne/following{/other_user}","gists_url":"https://api.github.com/users/martin-osborne/gists{/gist_id}","starred_url":"https://api.github.com/users/martin-osborne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/martin-osborne/subscriptions","organizations_url":"https://api.github.com/users/martin-osborne/orgs","repos_url":"https://api.github.com/users/martin-osborne/repos","events_url":"https://api.github.com/users/martin-osborne/events{/privacy}","received_events_url":"https://api.github.com/users/martin-osborne/received_events","type":"User","site_admin":false},"created_at":"2015-04-02T15:52:37Z","updated_at":"2015-04-02T15:52:37Z","body":"@DEvil0000 \r\n\r\nI've started to prepare a pull request for this.  However, in the example above, the matches you list are for sub-expression 1, which seems odd to me.  I'd expect the matches to be for sub-expression zero, i.e. \"abc1\", \"abc2\", and, \"abc3\".  In what I'm preparing to submit the first form of `matchAll` will return `[\"abc1\", \"abc2\", \"abc3\"]`.  The second form of `matchAll` will return `[[\"abc1\", \"1\"], [\"abc2\", \"2\"], [\"abc3\", \"3\"]]`, so it should give you what you need.\r\n\r\n```\r\n    int matchAll(const std::string& subject, std::string::size_type offset, MatchVec& matches, int options = 0) const;\r\n        /// Matches all the non-overlapping occurances of the subject string, starting at offset, against the pattern. \r\n        /// Returns the position of each matched substring in matches.\r\n        /// If no part of the subject matches the pattern, matches is empty.\r\n        /// Throws a RegularExpressionException in case of an error.\r\n        /// Returns the number of matches.\r\n\r\n    int matchAll(const std::string& subject, std::string::size_type offset, std::vector<MatchVec>& matches, int options = 0) const;\r\n        /// Matches all the non-overlapping occurances of the subject string, starting at offset, against the pattern. \r\n        /// For each match it returns the captured text for each subexpression in matches[i].\r\n        /// If no part of the subject matches the pattern, matches is empty.\r\n        /// Throws a RegularExpressionException in case of an error.\r\n        /// Returns the number of matches.\r\n```"}}