{"id":36373522,"url":"https://github.com/matecat/whole-text-finder","last_synced_at":"2026-01-11T14:03:29.337Z","repository":{"id":35090449,"uuid":"205207156","full_name":"matecat/whole-text-finder","owner":"matecat","description":"Whole Text Searcher","archived":false,"fork":false,"pushed_at":"2025-02-14T11:28:01.000Z","size":3287,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-28T22:02:52.798Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/matecat.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-08-29T16:36:57.000Z","updated_at":"2025-02-14T11:12:44.000Z","dependencies_parsed_at":"2023-12-15T18:46:03.667Z","dependency_job_id":"cc99afa9-640d-4d86-8aa2-53b7b41bd565","html_url":"https://github.com/matecat/whole-text-finder","commit_stats":{"total_commits":42,"total_committers":3,"mean_commits":14.0,"dds":0.0714285714285714,"last_synced_commit":"f692970455116fd8f8f408cc6ac59f7e4dc51075"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/matecat/whole-text-finder","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matecat%2Fwhole-text-finder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matecat%2Fwhole-text-finder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matecat%2Fwhole-text-finder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matecat%2Fwhole-text-finder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matecat","download_url":"https://codeload.github.com/matecat/whole-text-finder/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matecat%2Fwhole-text-finder/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28306985,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T11:18:18.743Z","status":"ssl_error","status_checked_at":"2026-01-11T11:07:56.842Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-11T14:03:29.272Z","updated_at":"2026-01-11T14:03:29.323Z","avatar_url":"https://github.com/matecat.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WholeTextFinder\n\n[![license](https://img.shields.io/github/license/matecat/whole-text-finder.svg)]()\n[![Packagist](https://img.shields.io/packagist/v/matecat/whole-text-finder.svg)]()\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/matecat/whole-text-finder/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/matecat/whole-text-finder/?branch=master)\n\n**WholeTextFinder** is a simple whole text finder.\n\n## Basic Usage\n\nUse the `find` method. Here is a basic search:\n\n```php\n//..\nuse Finder\\WholeTextFinder;\n\n$haystack  = \"PHP PHP is the #1 web scripting PHP language of choice.\";\n$needle = \"php\";\n\n// 3 matches\n$matches = WholeTextFinder::find($haystack, $needle);\n\n// $matches is equals to:\n//\n// array(3) {\n//    [0] =\u003e\n//  array(2) {\n//            [0] =\u003e\n//    string(3) \"PHP\"\n//            [1] =\u003e\n//    int(0)\n//  }\n//  [1] =\u003e\n//  array(2) {\n//            [0] =\u003e\n//    string(3) \"PHP\"\n//            [1] =\u003e\n//    int(4)\n//  }\n//  [2] =\u003e\n//  array(2) {\n//            [0] =\u003e\n//    string(3) \"PHP\"\n//            [1] =\u003e\n//    int(32)\n//  }\n// }\n\n```\n\n### Multi bytes strings\n\nPlease note that `WholeTextFinder::find` function is multi byte safe and returns the correct word positions in the original phrase. Take a look here:\n\n```php\n//..\nuse Finder\\WholeTextFinder;\n\n$haystack  = \"La casa è bella bella\";\n$needle = \"bella\";\n\n$matches = WholeTextFinder::find($haystack, $needle, true, true, true);\n\n// $matches is equals to:\n// array (\n//    0 =\u003e\n//        array (\n//            0 =\u003e 'bella',\n//            1 =\u003e 10,\n//        ),\n//    1 =\u003e\n//        array (\n//            0 =\u003e 'bella',\n//            1 =\u003e 16,\n//        ),\n//)\n\n```\n\n## Find and Replace\n\nThere is also available a `findAndReplace` method:\n\n```php\n//..\nuse Finder\\WholeTextFinder;\n\n$haystack = 'Δύο παράγοντες καθόρισαν την αντίληψή μου για την Τενεσί Ουίλιαμς και τη σκηνική παρουσίαση των κειμένων: η Maria Britneva και η Annette Saddik, αφετέρου.';\n$needle = 'και';\n$replacement = 'test';\n\n$matches = WholeTextFinder::findAndReplace($haystack, $needle, $replacement);\n\n// $matches is equals to:\n//\n// array(2) {\n//   [\"replacement\"]=\u003e\n//   string(252) \"Δύο παράγοντες καθόρισαν την αντίληψή μου για την Τενεσί Ουίλιαμς test τη σκηνική παρουσίαση των κειμένων: η Maria Britneva test η Annette Saddik, αφετέρου.\"\n//   [\"occurrencies\"]=\u003e\n//   array(2) {\n//     [0]=\u003e\n//     array(2) {\n//       [0]=\u003e\n//       string(6) \"και\"\n//       [1]=\u003e\n//       int(66)\n//     }\n//     [1]=\u003e\n//     array(2) {\n//       [0]=\u003e\n//       string(6) \"και\"\n//       [1]=\u003e\n//       int(123)\n//     }\n//   }\n// } \n//\n\n```\n\nThis method will automatically **exclude** from replace HTML and some Matecat special tags, but allows to replace the inner content inside HTML tags.\n\nSo, for example:\n\n```php\n//..\nuse Finder\\WholeTextFinder;\n\n// Example 1\n$haystack = \"Beauty -\u003e 2 Anti-Akne Gesichtsreiniger Schlankmacher \u003cg id=\\\"2\\\"\u003eXXX\u003c/g\u003e\";\n$needle = 2;\n$replacement = \"test\";\n\n$matches = WholeTextFinder::findAndReplace($haystack, $needle, $replacement);\n\n// $matches is equals to:\n//\n// array(2) {\n//   [\"replacement\"]=\u003e\n//   string(252) \"Beauty -\u003e test Anti-Akne Gesichtsreiniger Schlankmacher \u003cg id=\"2\"\u003eXXX\u003c/g\u003e\"\n//   [\"occurrencies\"]=\u003e\n//   array(1) {\n//    [0]=\u003e\n//      array(2) {\n//        [0]=\u003e\n//        string(1) \"2\"\n//        [1]=\u003e\n//        int(10)\n//     }\n//   }\n// } \n//\n\n// Example 2\n$haystack = \"Beauty -\u003e 2 Anti-Akne Gesichtsreiniger Schlankmacher \u003cg id=\\\"2\\\"\u003eXXX\u003c/g\u003e\";\n$needle = 'XXX';\n$replacement = \"test\";\n\n$matches = WholeTextFinder::findAndReplace($haystack, $needle, $replacement);\n\n// $matches is equals to:\n//\n// array(2) {\n//   [\"replacement\"]=\u003e\n//   string(252) \"Beauty -\u003e 2 Anti-Akne Gesichtsreiniger Schlankmacher \u003cg id=\"2\"\u003etest\u003c/g\u003e\"\n//   [\"occurrencies\"]=\u003e\n//   array(1) {\n//    [0]=\u003e\n//      array(2) {\n//        [0]=\u003e\n//        string(1) \"test\"\n//        [1]=\u003e\n//        int(55)\n//     }\n//   }\n// } \n//\n\n```\n\n## Search options\n\nSome options are avaliable:\n\nYou can also specify four options:\n\n* **$skipHtmlEntities** (`true` by default)  \n* **$exactMatch** (`false` by default) \n* **$caseSensitive** (`false` by default) \n* **$preserveNbsps** (`false` by default) \n\nHere are some examples:\n\n```php\n//..\nuse Finder\\WholeTextFinder;\n\n$haystack  = \"PHP PHP is the #1 web scripting PHP language of choice.\";\n\n// 0 matches\n$needle = \"php\";\n$matches = WholeTextFinder::find($haystack, $needle, true, true, true);\n   \n// 1 match \n$needle = \"#1\";\n$matches = WholeTextFinder::find($haystack, $needle, true, true, true);\n\n// 1 match, even if the haystack contains an invisible nbsp and the needle has an ordinary spacer\n$haystackWithNbsp  = \"Lawful basis for processing including basis of legitimate interest\";\n$needleWithoutNbsp = \"Lawful basis for processing including basis of legitimate interest\";\n$matches = WholeTextFinder::find($haystackWithNbsp, $needleWithoutNbsp, true, true, true);\n   \n```\n\n## Support\n\nIf you found an issue or had an idea please refer [to this section](https://github.com/mauretto78/whole-text-finder/issues).\n\n## Authors\n\n* **Mauro Cassani** - [github](https://github.com/mauretto78)\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatecat%2Fwhole-text-finder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatecat%2Fwhole-text-finder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatecat%2Fwhole-text-finder/lists"}