{"id":22828686,"url":"https://github.com/busterc/boundary-match","last_synced_at":"2025-03-31T01:17:54.662Z","repository":{"id":74997300,"uuid":"127994254","full_name":"busterc/boundary-match","owner":"busterc","description":":abcd: Regex string match that honors boundaries for targets prepended and/or appended with non-word characters.","archived":false,"fork":false,"pushed_at":"2018-08-25T22:03:20.000Z","size":81,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-19T06:59:22.648Z","etag":null,"topics":["boundaries","boundary","matching","regex","regex-match","regexp","regexp-match","regexp-search","regexp-special-characters","string-matching"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/busterc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2018-04-04T02:15:11.000Z","updated_at":"2023-09-08T17:38:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"99e65899-694d-4e3a-85ea-d873b2b8a8c0","html_url":"https://github.com/busterc/boundary-match","commit_stats":{"total_commits":8,"total_committers":1,"mean_commits":8.0,"dds":0.0,"last_synced_commit":"aa82ae33ed99568b7bd669cf52f5e15856322636"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/busterc%2Fboundary-match","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/busterc%2Fboundary-match/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/busterc%2Fboundary-match/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/busterc%2Fboundary-match/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/busterc","download_url":"https://codeload.github.com/busterc/boundary-match/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246399803,"owners_count":20770909,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["boundaries","boundary","matching","regex","regex-match","regexp","regexp-match","regexp-search","regexp-special-characters","string-matching"],"created_at":"2024-12-12T19:11:27.305Z","updated_at":"2025-03-31T01:17:54.641Z","avatar_url":"https://github.com/busterc.png","language":"JavaScript","readme":"# boundary-match [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Coverage percentage][coveralls-image]][coveralls-url]\n\n\u003e Regex string match and replace that honors boundaries for targets prepended and/or appended with non-word characters.\n\n## Installation\n\n```sh\n$ npm install --save boundary-match\n```\n\n## Usage\n\n```js\nconst boundaryMatch = require('boundary-match');\n\nboundaryMatch('(HotDog)', '(hotdog)', 'i');\n// =\u003e [ '(HotDog)', index: 0, input: '(HotDog)' ]\n\n// Q. But Why?\n// A. Because, these fail to work as expected:\n\n'(HotDog)'.match(/\\b\\(hotdog\\)\\b/i);\n// =\u003e null\n'(HotDog)'.match(new RegExp('\\\\b\\\\(hotdog\\\\)\\\\b', 'i'));\n// =\u003e null\n\n// When matching isn't enough... `replace`\nlet matched = boundaryMatch('Gimme a (HotDog)', '(HOTDOG)', 'i');\nboundaryMatch.replace(matched, 'Chili Dog!');\n// =\u003e Gimme a Chili Dog!\n```\n\n## API\n\n### `boundaryMatch(string, target[, flags])`\n\nIf the `target` is found in the `string`, it returns an `Array` containing the entire matched target as the first element; an `index` property for the start of the match; and an `input` property that contains the entire `string`. If there were no matches, `null` is returned.\n\n* #### `string`\n  * `Required` : `String` the string to be searched.\n* #### `target`\n  * `Required` : `String` the string to be found. Will be escaped using [`escape-string-regexp`](https://github.com/sindresorhus/escape-string-regexp).\n* #### `flags`\n  * `Optional` : `String` can have any combination of the following values:\n    * `i` : ignore case\n\n### `boundaryMatch.replace(match, target)`\n\nReturns a `String` that replaces the found `match` results with `target`\n\n* #### `match`\n  * `Required` : `Array` the result of previously calling `boundaryMatch`\n* #### `target`\n  * `Required` : `String` the string that replaces the found match\n\n## TODO\n\n* [] Implement other native `RegExp` flags: `g`,`u`, `m`, `y`\n\n## FYI\n\n* [https://www.ecma-international.org/ecma-262/8.0/index.html#sec-assertion](https://www.ecma-international.org/ecma-262/8.0/index.html#sec-assertion)\n\n## License\n\nISC © [Buster Collings](https://about.me/buster)\n\n[npm-image]: https://badge.fury.io/js/boundary-match.svg\n[npm-url]: https://npmjs.org/package/boundary-match\n[travis-image]: https://travis-ci.org/busterc/boundary-match.svg?branch=master\n[travis-url]: https://travis-ci.org/busterc/boundary-match\n[daviddm-image]: https://david-dm.org/busterc/boundary-match.svg?theme=shields.io\n[daviddm-url]: https://david-dm.org/busterc/boundary-match\n[coveralls-image]: https://coveralls.io/repos/busterc/boundary-match/badge.svg\n[coveralls-url]: https://coveralls.io/r/busterc/boundary-match\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbusterc%2Fboundary-match","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbusterc%2Fboundary-match","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbusterc%2Fboundary-match/lists"}