{"id":26021207,"url":"https://github.com/teclone/regex","last_synced_at":"2025-06-14T02:06:05.688Z","repository":{"id":38174849,"uuid":"179976601","full_name":"teclone/regex","owner":"teclone","description":"A module that builds on the existing RegExp module, making it easier working with text matching and replacement both in the browser and node environments","archived":false,"fork":false,"pushed_at":"2022-12-08T21:31:51.000Z","size":3753,"stargazers_count":0,"open_issues_count":20,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-11T14:44:53.792Z","etag":null,"topics":["placeholder-replacement","regex","replace","replace-callback","replace-text","string-matching"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/teclone.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-04-07T14:20:46.000Z","updated_at":"2021-01-14T00:25:42.000Z","dependencies_parsed_at":"2023-01-25T18:15:34.636Z","dependency_job_id":null,"html_url":"https://github.com/teclone/regex","commit_stats":null,"previous_names":["harrison-ifeanyichukwu/regex"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/teclone/regex","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teclone%2Fregex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teclone%2Fregex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teclone%2Fregex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teclone%2Fregex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/teclone","download_url":"https://codeload.github.com/teclone/regex/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teclone%2Fregex/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259747234,"owners_count":22905312,"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":["placeholder-replacement","regex","replace","replace-callback","replace-text","string-matching"],"created_at":"2025-03-06T08:50:29.823Z","updated_at":"2025-06-14T02:06:05.669Z","avatar_url":"https://github.com/teclone.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Regex\n\n[![Build Status](https://travis-ci.org/teclone/regex.svg?branch=master)](https://travis-ci.org/teclone/regex)\n[![Coverage Status](https://coveralls.io/repos/github/teclone/regex/badge.svg?branch=master)](https://coveralls.io/github/teclone/regex?branch=master)\n[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)\n[![npm version](https://badge.fury.io/js/%40teclone%2Fregex.svg)](https://badge.fury.io/js/%40teclone%2Fregex)\n![npm](https://img.shields.io/npm/dt/%40teclone%2Fregex.svg)\n\nRegex is a module that builds on the existing `RegExp` module, making it easier working with text matching and replacment in JavaScript both in the `browser` and in `Node.JS` environment.\n\n**Single Browser distributable bundle is located inside **dist** folder.**\n\n## Installation\n\n```bash\nnpm install @teclone/regex\n```\n\n## Usage Sample\n\n```typescript\nimport { replace } from '@teclone/regex';\n\nlet text = 'Is is Is is Is';\n\nconsole.log(replace('is', 'are', text)); // are are are are are\n\n// respect case (case sensitive)\nconsole.log(replace('is', 'are', text, true)); // Is are Is are Is\n\n// replace only first occurence, case sensitive false\nconsole.log(replace('is', 'are', text, false, 1)); // are is Is is Is\n\n// replace only first 2 occurences, case sensitive false\nconsole.log(replace('is', 'are', text, false, 2)); // are are Is is Is\n```\n\n## Replacing with a Callback method\n\n```typescript\nimport { replaceCallback } from '@teclone/regex';\n\nconst text = 'He loves her';\nconsole.log(\n  replaceCallback(\n    ['he', 'she'],\n    function(matches, count) {\n      if (matches[0].toLowerCase() === 'he') return 'She';\n      else {\n        return 'him';\n      }\n    },\n    text,\n  ),\n); // logs She loves him\n```\n\n## Referencing captured groups in replacement text\n\nto reference a captured parameter in replacement text, use the format `$:number`. e.g **\\$:1**, **\\$:2**, **\\$:3**\n\n```typescript\nimport {replace} from '@teclone/regex';\n\nconst text = '2222 is the amount';\nconsole.log(\n    replace(/(\\d+)/, '$$:1', text)).toEqual('$2222 is the amount')\n);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteclone%2Fregex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fteclone%2Fregex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteclone%2Fregex/lists"}