{"action":"created","issue":{"url":"https://api.github.com/repos/VerbalExpressions/JSVerbalExpressions/issues/139","repository_url":"https://api.github.com/repos/VerbalExpressions/JSVerbalExpressions","labels_url":"https://api.github.com/repos/VerbalExpressions/JSVerbalExpressions/issues/139/labels{/name}","comments_url":"https://api.github.com/repos/VerbalExpressions/JSVerbalExpressions/issues/139/comments","events_url":"https://api.github.com/repos/VerbalExpressions/JSVerbalExpressions/issues/139/events","html_url":"https://github.com/VerbalExpressions/JSVerbalExpressions/issues/139","id":133439021,"number":139,"title":"Make a captured group optional","user":{"login":"RomainGoncalves","id":1366477,"avatar_url":"https://avatars.githubusercontent.com/u/1366477?v=3","gravatar_id":"","url":"https://api.github.com/users/RomainGoncalves","html_url":"https://github.com/RomainGoncalves","followers_url":"https://api.github.com/users/RomainGoncalves/followers","following_url":"https://api.github.com/users/RomainGoncalves/following{/other_user}","gists_url":"https://api.github.com/users/RomainGoncalves/gists{/gist_id}","starred_url":"https://api.github.com/users/RomainGoncalves/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RomainGoncalves/subscriptions","organizations_url":"https://api.github.com/users/RomainGoncalves/orgs","repos_url":"https://api.github.com/users/RomainGoncalves/repos","events_url":"https://api.github.com/users/RomainGoncalves/events{/privacy}","received_events_url":"https://api.github.com/users/RomainGoncalves/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-02-13T14:55:44Z","updated_at":"2016-02-13T20:40:59Z","closed_at":null,"body":"Hey,\r\n\r\nI was just wondering how I can get a captured group optional? Basically just adding '?' at the end of the group.\r\n\r\nI have this so far:\r\n```\r\njavascript\r\nvar regex = VerEx()\r\n      .startOfLine()\r\n      .then(code)\r\n      .then('_')\r\n      .range('0', 9)\r\n      .oneOrMore()\r\n      .then(letter)\r\n      .beginCapture()\r\n      .then('_')\r\n      .range('0', 9)\r\n      .oneOrMore()\r\n      .endCapture();\r\n```\r\n\r\nWhich gives me this: ```\r\n^(?:COO)(?:_)[0-9]+(?:A)((?:_)[0-9]+)/gm```\r\n\r\nGood, but I'd like: ```\r\n^(?:COO)(?:_)[0-9]+(?:A)((?:_)[0-9]+)?/gm```\r\n\r\nI'm trying to match:\r\nCOO_001A\r\nCOO_001A_1\r\nCOO_001A_9\r\nCOO_001A_11\r\nCOO_022222201A_1122222\r\n\r\nAnd so far, they all match but not: COO_001A"},"comment":{"url":"https://api.github.com/repos/VerbalExpressions/JSVerbalExpressions/issues/comments/183752333","html_url":"https://github.com/VerbalExpressions/JSVerbalExpressions/issues/139#issuecomment-183752333","issue_url":"https://api.github.com/repos/VerbalExpressions/JSVerbalExpressions/issues/139","id":183752333,"user":{"login":"ionutvmi","id":3531898,"avatar_url":"https://avatars.githubusercontent.com/u/3531898?v=3","gravatar_id":"","url":"https://api.github.com/users/ionutvmi","html_url":"https://github.com/ionutvmi","followers_url":"https://api.github.com/users/ionutvmi/followers","following_url":"https://api.github.com/users/ionutvmi/following{/other_user}","gists_url":"https://api.github.com/users/ionutvmi/gists{/gist_id}","starred_url":"https://api.github.com/users/ionutvmi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ionutvmi/subscriptions","organizations_url":"https://api.github.com/users/ionutvmi/orgs","repos_url":"https://api.github.com/users/ionutvmi/repos","events_url":"https://api.github.com/users/ionutvmi/events{/privacy}","received_events_url":"https://api.github.com/users/ionutvmi/received_events","type":"User","site_admin":false},"created_at":"2016-02-13T20:40:59Z","updated_at":"2016-02-13T20:40:59Z","body":"Since we don't have a method for it you can always use the `add` method to append a custom part.\r\n```\r\nVerEx()\r\n      .startOfLine()\r\n      .then('COO')\r\n      .then('_')\r\n      .range(0, 9)\r\n      .oneOrMore()\r\n      .then('A')\r\n      .beginCapture()\r\n      .then('_')\r\n      .range(0, 9)\r\n      .oneOrMore()\r\n      .endCapture()\r\n      .add('?');\r\n```"}}