{"action":"created","issue":{"url":"https://api.github.com/repos/SimpleRegex/SRL-JavaScript/issues/3","repository_url":"https://api.github.com/repos/SimpleRegex/SRL-JavaScript","labels_url":"https://api.github.com/repos/SimpleRegex/SRL-JavaScript/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/SimpleRegex/SRL-JavaScript/issues/3/comments","events_url":"https://api.github.com/repos/SimpleRegex/SRL-JavaScript/issues/3/events","html_url":"https://github.com/SimpleRegex/SRL-JavaScript/issues/3","id":178828013,"number":3,"title":".exec() return only first result","user":{"login":"GeekEdem","id":10598614,"avatar_url":"https://avatars.githubusercontent.com/u/10598614?v=3","gravatar_id":"","url":"https://api.github.com/users/GeekEdem","html_url":"https://github.com/GeekEdem","followers_url":"https://api.github.com/users/GeekEdem/followers","following_url":"https://api.github.com/users/GeekEdem/following{/other_user}","gists_url":"https://api.github.com/users/GeekEdem/gists{/gist_id}","starred_url":"https://api.github.com/users/GeekEdem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GeekEdem/subscriptions","organizations_url":"https://api.github.com/users/GeekEdem/orgs","repos_url":"https://api.github.com/users/GeekEdem/repos","events_url":"https://api.github.com/users/GeekEdem/events{/privacy}","received_events_url":"https://api.github.com/users/GeekEdem/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-09-23T09:27:26Z","updated_at":"2016-09-23T10:05:12Z","closed_at":null,"body":"Hello. I have issue with returning all results to variable in JS. I build simple [test](https://simple-regex.com/build/57e4f3bc78e82), but when use\r\n```\r\nconst SRL = require('srl');\r\nconst query = new SRL(query);\r\nconsole.log(query.exec(query));\r\n```\r\nIn console recieve:\r\n```\r\n[ 'What',\r\n  'What',\r\n  index: 0,\r\n  input: 'What is Lorem Ipsum? ... ' ]\r\n```\r\n\r\nBut what about all other? And why `What` is 2 times?\r\nThanks."},"comment":{"url":"https://api.github.com/repos/SimpleRegex/SRL-JavaScript/issues/comments/249152874","html_url":"https://github.com/SimpleRegex/SRL-JavaScript/issues/3#issuecomment-249152874","issue_url":"https://api.github.com/repos/SimpleRegex/SRL-JavaScript/issues/3","id":249152874,"user":{"login":"jsenjoy","id":4496552,"avatar_url":"https://avatars.githubusercontent.com/u/4496552?v=3","gravatar_id":"","url":"https://api.github.com/users/jsenjoy","html_url":"https://github.com/jsenjoy","followers_url":"https://api.github.com/users/jsenjoy/followers","following_url":"https://api.github.com/users/jsenjoy/following{/other_user}","gists_url":"https://api.github.com/users/jsenjoy/gists{/gist_id}","starred_url":"https://api.github.com/users/jsenjoy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsenjoy/subscriptions","organizations_url":"https://api.github.com/users/jsenjoy/orgs","repos_url":"https://api.github.com/users/jsenjoy/repos","events_url":"https://api.github.com/users/jsenjoy/events{/privacy}","received_events_url":"https://api.github.com/users/jsenjoy/received_events","type":"User","site_admin":false},"created_at":"2016-09-23T10:05:12Z","updated_at":"2016-09-23T10:05:12Z","body":"In JavaScript, Regex is always take the `first-match`, but not all, unless given the `g` flag.\r\n\r\nIn this case, you should use like this: `query.all().exec('...')` .\r\n\r\nAnd I will make a commit to take a key like `global` in the interpreter later for SRL-JavaScript to add `g` flag.\r\n\r\nAbout the `exec`，if you want to take all results matched in a regex with `g` flag, you should use a loop like:\r\n\r\n```js\r\nconst myRe = /ab*/g;\r\nconst str = 'abbcdefabh';\r\nlet myArray;\r\nwhile ((myArray = myRe.exec(str)) !== null) {\r\n  var msg = 'Found ' + myArray[0] + '. ';\r\n  msg += 'Next match starts at ' + myRe.lastIndex;\r\n  console.log(msg);\r\n}\r\n```\r\n\r\nMore details: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/exec"}}
{"actor":{"display_login":"jsenjoy"}}