{"id":17284632,"url":"https://github.com/rangoo94/find-regexp-beginning","last_synced_at":"2025-03-26T16:25:50.769Z","repository":{"id":57236328,"uuid":"121403264","full_name":"rangoo94/find-regexp-beginning","owner":"rangoo94","description":"Find character which could be on regexp beginning","archived":false,"fork":false,"pushed_at":"2018-02-13T16:11:30.000Z","size":37,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-02T06:18:52.219Z","etag":null,"topics":["analysis","character","parser","regexp"],"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/rangoo94.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":"2018-02-13T16:02:54.000Z","updated_at":"2019-09-29T18:07:05.000Z","dependencies_parsed_at":"2022-08-23T16:20:16.173Z","dependency_job_id":null,"html_url":"https://github.com/rangoo94/find-regexp-beginning","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rangoo94%2Ffind-regexp-beginning","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rangoo94%2Ffind-regexp-beginning/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rangoo94%2Ffind-regexp-beginning/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rangoo94%2Ffind-regexp-beginning/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rangoo94","download_url":"https://codeload.github.com/rangoo94/find-regexp-beginning/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245691010,"owners_count":20656689,"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":["analysis","character","parser","regexp"],"created_at":"2024-10-15T09:54:35.996Z","updated_at":"2025-03-26T16:25:50.744Z","avatar_url":"https://github.com/rangoo94.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Find RegExp beginning\n\n[![Travis](https://travis-ci.org/rangoo94/find-regexp-beginning.svg)](https://travis-ci.org/rangoo94/find-regexp-beginning)\n[![Code Climate](https://codeclimate.com/github/rangoo94/find-regexp-beginning/badges/gpa.svg)](https://codeclimate.com/github/rangoo94/find-regexp-beginning)\n[![Coverage Status](https://coveralls.io/repos/github/rangoo94/find-regexp-beginning/badge.svg?branch=master)](https://coveralls.io/github/rangoo94/find-regexp-beginning?branch=master)\n[![NPM Downloads](https://img.shields.io/npm/dm/find-regexp-beginning.svg)](https://www.npmjs.com/package/find-regexp-beginning)\n\nUseful, when you need to to detect what could be the first character which will pass regular expression (i.e. for lexer optimizations)\n\n## How to install\n\nPackage is available as `find-regexp-beginning` in NPM, so you can use it in your project using\n`npm install find-regexp-beginning` or `yarn add find-regexp-beginning`\n\n## What are requirements?\n\nCode itself is written in ES6 and should work in Node.js 4+ environment (best in Node.js 9+).\nIf you would like to use it in browser or older development, there is also transpiled and bundled (UMD) version included.\nYou can use `find-regexp-beginning/browser` in your requires or `FindRegexpBeginning` in global environment (in browser):\n\n```js\n// Load library\nconst findRegexpBeginning = require('find-regexp-beginning/browser')\n\nconst result = findRegexpBeginning(/abc/i) // [ 'a', 'A' ]\n```\n\n## How to use it?\n\nMost importantly first argument is `RegExp` instance.\n\n```js\nconst findRegexpBeginning = require('find-regexp-beginning')\n\nconst result1 = findRegexpBeginning(/abc/) // [ 'a' ]\nconst result2 = findRegexpBeginning(/abc/i) // [ 'a', 'A' ]\n```\n\nThis function returns either list of possible characters on beginning\nor `null` (when there is negation or any object is accepted).\n\nAdditionally, there is second argument `maxCharacters` (default: `15`).\nIt's important when you want to not detect characters if they exceed number of maximum characters,\ni.e.:\n\n```js\nconst findRegexpBeginning = require('find-regexp-beginning')\n\nconst result1 = findRegexpBeginning(/[1-9]/) // [ '1', '2', '3', '4', '5', '6', '7', '8', '9' ]\nconst result2 = findRegexpBeginning(/[1-9]/, 9) // [ '1', '2', '3', '4', '5', '6', '7', '8', '9' ]\nconst result3 = findRegexpBeginning(/[1-9]/, 100) // [ '1', '2', '3', '4', '5', '6', '7', '8', '9' ]\nconst result4 = findRegexpBeginning(/[1-9]/, Infinity) // [ '1', '2', '3', '4', '5', '6', '7', '8', '9' ]\nconst result5 = findRegexpBeginning(/[1-9]/, 3) // null\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frangoo94%2Ffind-regexp-beginning","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frangoo94%2Ffind-regexp-beginning","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frangoo94%2Ffind-regexp-beginning/lists"}