{"id":18358796,"url":"https://github.com/uppercod/str-fragment","last_synced_at":"2026-02-25T19:34:34.286Z","repository":{"id":54405157,"uuid":"278780602","full_name":"UpperCod/str-fragment","owner":"UpperCod","description":"Capture text blocks based on regular expressions","archived":false,"fork":false,"pushed_at":"2024-09-27T06:34:18.000Z","size":131,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-01T04:45:25.817Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/UpperCod.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-11T03:32:15.000Z","updated_at":"2021-05-12T13:53:14.000Z","dependencies_parsed_at":"2024-10-25T20:10:25.368Z","dependency_job_id":"0e5c5318-a0c3-4410-b0c1-593fbf282896","html_url":"https://github.com/UpperCod/str-fragment","commit_stats":null,"previous_names":["uppercod/str_fragment"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/UpperCod/str-fragment","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UpperCod%2Fstr-fragment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UpperCod%2Fstr-fragment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UpperCod%2Fstr-fragment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UpperCod%2Fstr-fragment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/UpperCod","download_url":"https://codeload.github.com/UpperCod/str-fragment/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UpperCod%2Fstr-fragment/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273619271,"owners_count":25138237,"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","status":"online","status_checked_at":"2025-09-04T02:00:08.968Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":"2024-11-05T22:19:26.605Z","updated_at":"2025-10-28T14:14:16.686Z","avatar_url":"https://github.com/UpperCod.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# str-replace\n\nCapture text fragments based on regular expressions that are executed for each line of the text.\n\n## Install\n\n```bash\nnpm install @uppercod/str-fragment\n```\n\n## Example\n\n```js\nimport { getFragments, replaceFragments } from \"@uppercod/str-fragment\";\n\nlet str = `\n/**\n * old comment\n */\nlet s = \"\";\n`;\n\n/**@type {import(\"str-fragment/internal\").captures}*/\nlet fragments = getFragment(str, {\n    open: /\\/\\*\\*/,\n    end: /\\*\\//,\n    equal: false, // if fragments share capture equality set equal to true\n});\n\nreplaceFragments(str, fragments, () =\u003e `/** new comment */`);\n// /** new comment */\n// let s = \"\";\n```\n\n## more expressions\n\n**template-string**\n\n```js\nlet blocks = getFragments(code, {\n    open: /css`/,\n    end: /`/,\n});\n```\n\n**frontmatter**\n\n```js\nlet blocks = getFragments(code, {\n    open: /^---/m,\n    end: /^---/m,\n    equal: true,\n});\n```\n\n## Api\n\n### replaceFragments\n\nReplace the fragments with a new text, if null returns no replacement of the evaluated fragment is generated\n\n### walkFragments\n\nWalk on the shards generate changes\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuppercod%2Fstr-fragment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuppercod%2Fstr-fragment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuppercod%2Fstr-fragment/lists"}