{"action":"closed","issue":{"url":"https://api.github.com/repos/kangax/compat-table/issues/696","labels_url":"https://api.github.com/repos/kangax/compat-table/issues/696/labels{/name}","comments_url":"https://api.github.com/repos/kangax/compat-table/issues/696/comments","events_url":"https://api.github.com/repos/kangax/compat-table/issues/696/events","html_url":"https://github.com/kangax/compat-table/issues/696","id":118088067,"number":696,"title":"RegExp copy constructor","user":{"login":"abozhilov","id":191849,"avatar_url":"https://avatars.githubusercontent.com/u/191849?v=3","gravatar_id":"","url":"https://api.github.com/users/abozhilov","html_url":"https://github.com/abozhilov","followers_url":"https://api.github.com/users/abozhilov/followers","following_url":"https://api.github.com/users/abozhilov/following{/other_user}","gists_url":"https://api.github.com/users/abozhilov/gists{/gist_id}","starred_url":"https://api.github.com/users/abozhilov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abozhilov/subscriptions","organizations_url":"https://api.github.com/users/abozhilov/orgs","repos_url":"https://api.github.com/users/abozhilov/repos","events_url":"https://api.github.com/users/abozhilov/events{/privacy}","received_events_url":"https://api.github.com/users/abozhilov/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-11-20T17:31:11Z","updated_at":"2015-11-20T19:02:24Z","closed_at":"2015-11-20T19:02:24Z","body":"According to `21.2.3.1` point 5, RegExp constructor can be used to copy existing regex object. \r\n\r\n```javascript\r\nlet r = /abc/g;\r\nnew RegExp(r) !== r; // true\r\n```\r\n\r\nAs well in this form of copying can be set/reset flags: \r\n\r\n```javascript\r\nlet r = /abc/g;\r\nlet r1 = new RegExp(r, 'i');\r\nlet r2 = new RegExp(r, r.flags + 'i');\r\n\r\nr1.flags; // i\r\nr2.flags; //gi\r\n```\r\n\r\nHope all of the engines will implement that feature as just copying existing NFA instead of recompiling the regex again. \r\n"}}