{"action":"created","issue":{"url":"https://api.github.com/repos/mathiasbynens/regenerate/issues/28","labels_url":"https://api.github.com/repos/mathiasbynens/regenerate/issues/28/labels{/name}","comments_url":"https://api.github.com/repos/mathiasbynens/regenerate/issues/28/comments","events_url":"https://api.github.com/repos/mathiasbynens/regenerate/issues/28/events","html_url":"https://github.com/mathiasbynens/regenerate/issues/28","id":55367857,"number":28,"title":"Matching lone surrogates *only*","user":{"login":"mathiasbynens","id":81942,"avatar_url":"https://avatars.githubusercontent.com/u/81942?v=3","gravatar_id":"","url":"https://api.github.com/users/mathiasbynens","html_url":"https://github.com/mathiasbynens","followers_url":"https://api.github.com/users/mathiasbynens/followers","following_url":"https://api.github.com/users/mathiasbynens/following{/other_user}","gists_url":"https://api.github.com/users/mathiasbynens/gists{/gist_id}","starred_url":"https://api.github.com/users/mathiasbynens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mathiasbynens/subscriptions","organizations_url":"https://api.github.com/users/mathiasbynens/orgs","repos_url":"https://api.github.com/users/mathiasbynens/repos","events_url":"https://api.github.com/users/mathiasbynens/events{/privacy}","received_events_url":"https://api.github.com/users/mathiasbynens/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-01-24T11:20:43Z","updated_at":"2015-01-30T16:10:20Z","closed_at":null,"body":"See https://github.com/mathiasbynens/regexpu/issues/16 and https://gist.github.com/mathiasbynens/bbe7f870208abcfec860.\r\n\r\n```js\r\nvar set = regenerate()\r\n  .addRange(0xD800, 0xDBFF) // lone high surrogates\r\n  .addRange(0xDC00, 0xDFFF); // lone low surrogates\r\n\r\nvar match = '𝌆'.match(RegExp('(' + set.toString() + ')'));\r\nconsole.log(match == null);\r\n// expected: true\r\n// actual: false, since the surrogate halves are matched\r\n```\r\n\r\nInstead, it would make more sense to match lone surrogates *only* in such cases."},"comment":{"url":"https://api.github.com/repos/mathiasbynens/regenerate/issues/comments/72224808","html_url":"https://github.com/mathiasbynens/regenerate/issues/28#issuecomment-72224808","issue_url":"https://api.github.com/repos/mathiasbynens/regenerate/issues/28","id":72224808,"user":{"login":"mathiasbynens","id":81942,"avatar_url":"https://avatars.githubusercontent.com/u/81942?v=3","gravatar_id":"","url":"https://api.github.com/users/mathiasbynens","html_url":"https://github.com/mathiasbynens","followers_url":"https://api.github.com/users/mathiasbynens/followers","following_url":"https://api.github.com/users/mathiasbynens/following{/other_user}","gists_url":"https://api.github.com/users/mathiasbynens/gists{/gist_id}","starred_url":"https://api.github.com/users/mathiasbynens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mathiasbynens/subscriptions","organizations_url":"https://api.github.com/users/mathiasbynens/orgs","repos_url":"https://api.github.com/users/mathiasbynens/repos","events_url":"https://api.github.com/users/mathiasbynens/events{/privacy}","received_events_url":"https://api.github.com/users/mathiasbynens/received_events","type":"User","site_admin":false},"created_at":"2015-01-30T16:10:20Z","updated_at":"2015-01-30T16:10:20Z","body":"Consider these three tests:\r\n\r\n```js\r\nconsole.log(regex.test('a\\uD834b')); // expected: true; actual: true\r\nconsole.log(regex.test('a\\uDC00b')); // expected: true; actual: false\r\nconsole.log(regex.test('a\\uD834\\uDF06b')); // expected: false; actual: false\r\n```\r\n\r\nThere are two options:\r\n\r\na. Either we pass test 1 and 3 (as in the current implementation in v1.2.1) but fail test 2, or…\r\nb. We pass test 1 and 2 but fail test 3.\r\n\r\nWhich is the lesser evil — a or b?"}}