{"action":"created","issue":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/18842","repository_url":"https://api.github.com/repos/elastic/elasticsearch","labels_url":"https://api.github.com/repos/elastic/elasticsearch/issues/18842/labels{/name}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/18842/comments","events_url":"https://api.github.com/repos/elastic/elasticsearch/issues/18842/events","html_url":"https://github.com/elastic/elasticsearch/pull/18842","id":159983592,"number":18842,"title":"Add support for /regex/","user":{"login":"nik9000","id":215970,"avatar_url":"https://avatars.githubusercontent.com/u/215970?v=3","gravatar_id":"","url":"https://api.github.com/users/nik9000","html_url":"https://github.com/nik9000","followers_url":"https://api.github.com/users/nik9000/followers","following_url":"https://api.github.com/users/nik9000/following{/other_user}","gists_url":"https://api.github.com/users/nik9000/gists{/gist_id}","starred_url":"https://api.github.com/users/nik9000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nik9000/subscriptions","organizations_url":"https://api.github.com/users/nik9000/orgs","repos_url":"https://api.github.com/users/nik9000/repos","events_url":"https://api.github.com/users/nik9000/events{/privacy}","received_events_url":"https://api.github.com/users/nik9000/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/elastic/elasticsearch/labels/:Plugin%20Lang%20Painless","name":":Plugin Lang Painless","color":"009800"},{"url":"https://api.github.com/repos/elastic/elasticsearch/labels/review","name":"review","color":"0052cc"},{"url":"https://api.github.com/repos/elastic/elasticsearch/labels/v5.0.0","name":"v5.0.0","color":"dddddd"},{"url":"https://api.github.com/repos/elastic/elasticsearch/labels/WIP","name":"WIP","color":"fef2c0"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2016-06-13T15:51:51Z","updated_at":"2016-06-13T18:32:52Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/18842","html_url":"https://github.com/elastic/elasticsearch/pull/18842","diff_url":"https://github.com/elastic/elasticsearch/pull/18842.diff","patch_url":"https://github.com/elastic/elasticsearch/pull/18842.patch"},"body":"Adds `/regex/` as a regex constructor. A couple of fun points:\r\n1. This makes generic the idea of arbitrary stuff adding a constant.\r\nBoth SFunction and LRegex create a statically initialized constant.\r\nBoth go through Locals to do this because they LRegex isn't directly\r\niterable from SScript.\r\n2. Differentiating `/` as-in-division from `/` as-in-start-of-regex\r\nis hard. See:\r\nhttp://www-archive.mozilla.org/js/language/js20-2002-04/rationale/syntax.html#regular-expressions\r\nThe javascript folks have a way, way tougher time of it then we do\r\nbecause they have semicolon insertion. We have the much simpler\r\ndelimiter rules. Even with our simpler life we still have to add\r\na hack to get lexing `/regex/` to work properly. I chose to add\r\ntoken-level lookbehind because it seems to be a pretty contained hack.\r\nI considered and rejected lexer modes, a lexer member variable,\r\nhaving the parser set variables on the lexer (this is a fairly common\r\nsolution for js, I believe), and moving regex parsing to the parser\r\nlevel.\r\n3. I've only added a very small subset of java.util.regex to the\r\nwhitelist because it is the subset I needed to test LRegex sanely.\r\nMore deserves to be added, and maybe more regex syntax like `=~` and\r\n`==~`. Those can probably be added without too much pain."},"comment":{"url":"https://api.github.com/repos/elastic/elasticsearch/issues/comments/225668609","html_url":"https://github.com/elastic/elasticsearch/pull/18842#issuecomment-225668609","issue_url":"https://api.github.com/repos/elastic/elasticsearch/issues/18842","id":225668609,"user":{"login":"nik9000","id":215970,"avatar_url":"https://avatars.githubusercontent.com/u/215970?v=3","gravatar_id":"","url":"https://api.github.com/users/nik9000","html_url":"https://github.com/nik9000","followers_url":"https://api.github.com/users/nik9000/followers","following_url":"https://api.github.com/users/nik9000/following{/other_user}","gists_url":"https://api.github.com/users/nik9000/gists{/gist_id}","starred_url":"https://api.github.com/users/nik9000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nik9000/subscriptions","organizations_url":"https://api.github.com/users/nik9000/orgs","repos_url":"https://api.github.com/users/nik9000/repos","events_url":"https://api.github.com/users/nik9000/events{/privacy}","received_events_url":"https://api.github.com/users/nik9000/received_events","type":"User","site_admin":false},"created_at":"2016-06-13T18:32:52Z","updated_at":"2016-06-13T18:32:52Z","body":"> The only question I have left is should the predicates in the lexer be on the right side of the rules?\r\n\r\nI've moved it to the right side and it seems to be being called far fewer times. I just checked by debugging  it, but that seems like a good thing?"}}
{"actor":{"display_login":"nik9000"}}