{"action":"created","issue":{"url":"https://api.github.com/repos/vqmod/vqmod/issues/16","labels_url":"https://api.github.com/repos/vqmod/vqmod/issues/16/labels{/name}","comments_url":"https://api.github.com/repos/vqmod/vqmod/issues/16/comments","events_url":"https://api.github.com/repos/vqmod/vqmod/issues/16/events","html_url":"https://github.com/vqmod/vqmod/issues/16","id":53701004,"number":16,"title":"[Feature Request] Multiline Search","user":{"login":"timint","id":359192,"avatar_url":"https://avatars.githubusercontent.com/u/359192?v=3","gravatar_id":"","url":"https://api.github.com/users/timint","html_url":"https://github.com/timint","followers_url":"https://api.github.com/users/timint/followers","following_url":"https://api.github.com/users/timint/following{/other_user}","gists_url":"https://api.github.com/users/timint/gists{/gist_id}","starred_url":"https://api.github.com/users/timint/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timint/subscriptions","organizations_url":"https://api.github.com/users/timint/orgs","repos_url":"https://api.github.com/users/timint/repos","events_url":"https://api.github.com/users/timint/events{/privacy}","received_events_url":"https://api.github.com/users/timint/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-01-08T00:34:58Z","updated_at":"2015-06-02T00:39:03Z","closed_at":null,"body":"I would like to push for a discussion of multiline search support.\r\nHere is something I came up with that could be useful for starters:\r\n\r\n    function preg_replacement_quote($string) {\r\n      return preg_replace('#(\\$|\\\\\\\\)(?=\\d)#', '\\\\\\\\\\1', $string);\r\n    }\r\n\r\n    function modify_string($haystack, $search, $insert, $operation) {\r\n      \r\n      $search_regexp = preg_split(\"#\\R+#\", trim($search)); // Convert multiple lines to array\r\n      foreach(array_keys($search_regexp) as $key) {\r\n        $search_regexp[$key] = preg_quote(trim($search_regexp[$key]), '#'); // Turn line into regular expression\r\n      }\r\n      $search_regexp = \"#(\\\\s+?\" . implode('\\\\s+', $search_regexp) . \"\\\\s+?)#\"; // Glue\r\n      \r\n      switch($operation) {\r\n        case 'prepend':\r\n          return preg_replace($search_regexp, '$1' . $insert, $haystack);\r\n        case 'replace':\r\n          return preg_replace($search_regexp, $insert, $haystack);\r\n        case 'append':\r\n          return preg_replace($search_regexp, preg_replacement_quote($insert) . '$1', $haystack);\r\n        default:\r\n          trigger_error(\"Unknown operation ($operation)\", E_USER_ERROR);\r\n      }\r\n    }\r\n\r\nThe code should not be used for production. I had some troubles escaping $insert where PHP replaced both $1 and \\\\1 with the first matched pair."},"comment":{"url":"https://api.github.com/repos/vqmod/vqmod/issues/comments/107753713","html_url":"https://github.com/vqmod/vqmod/issues/16#issuecomment-107753713","issue_url":"https://api.github.com/repos/vqmod/vqmod/issues/16","id":107753713,"user":{"login":"JAY6390","id":696920,"avatar_url":"https://avatars.githubusercontent.com/u/696920?v=3","gravatar_id":"","url":"https://api.github.com/users/JAY6390","html_url":"https://github.com/JAY6390","followers_url":"https://api.github.com/users/JAY6390/followers","following_url":"https://api.github.com/users/JAY6390/following{/other_user}","gists_url":"https://api.github.com/users/JAY6390/gists{/gist_id}","starred_url":"https://api.github.com/users/JAY6390/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JAY6390/subscriptions","organizations_url":"https://api.github.com/users/JAY6390/orgs","repos_url":"https://api.github.com/users/JAY6390/repos","events_url":"https://api.github.com/users/JAY6390/events{/privacy}","received_events_url":"https://api.github.com/users/JAY6390/received_events","type":"User","site_admin":false},"created_at":"2015-06-02T00:39:03Z","updated_at":"2015-06-02T00:39:03Z","body":"Hi Tim\r\n\r\nMore than happy to hear ideas for improvements. Feel free to e-mail me jay [at] jaygilford [dot] com\r\n\r\nKind regards\r\nJay"}}