Regex tester: add the `v` flag, and step over emoji correctly when it's on
维护者通常 1 天内回复
评估
- 难度
- 3/5
- 预计耗时
- 半天
- 新手友好度
- 82/100
- Issue 类型
- 功能
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- nextjs, react, typescript
调研方向
Start in lib/regex-utils.ts: read compileRegex (line 16) and the empty-match step in findMatches (line 49), then add the issue's table rows to lib/__tests__/regex-utils.test.ts near the u flag test (line 53) and watch them fail. Fix the step to re.unicode || re.unicodeSets and make compileRegex reject u+v. Then add the v button with toggleFlag exclusivity in app/(tools)/regex-tester/RegexTesterClient.tsx and its test, and update the flag list in lib/tools.ts (line 717). Done when the table rows match, both buttons show aria-pressed, and lint, test and build pass.
由索引模型根据 Issue 内容生成。
描述
The flag buttons offer g, i, m, s, u and y (app/(tools)/regex-tester/RegexTesterClient.tsx, lines 7 to 14), but not v (unicodeSets). Every current browser supports it, and patterns like [\p{L}--[a-z]] or \p{RGI_Emoji} only work with it. compileRegex already accepts v (lib/regex-utils.ts, line 17), so it's only missing from the UI.
Adding the button on its own would expose a bug in findMatches. After an empty match it steps forward two code units only when re.unicode is true (line 49), and re.unicode is false for a v regex. So it steps into the middle of an emoji, the engine moves back to the start of it, and the same empty match comes back until the 1,000 limit:
| Pattern | Flags | Text | findMatches now |
Expected |
|---|---|---|---|---|
| (empty) | gu |
😀a |
3 matches, at 0, 2, 3 | the same |
| (empty) | gv |
😀a |
1,000 matches at index 0, truncated: true |
3 matches, at 0, 2, 3 |
x* |
gv |
😀😀 |
1,000 matches at index 0 | 3 matches, at 0, 2, 4 |
(?:) |
gv |
a😀b |
1,000 matches, at 0 and then 1 over and over | 4 matches, at 0, 1, 3, 4 |
The replace preview already gets these right, because String.replace handles v itself.
What to do
- Add a
vbutton afteru, with a title like "Unicode sets: set operations and string properties".uandvcan't be used together (new RegExp("a", "uv")throws), so turning one on intoggleFlag(line 68) turns the other off. - In
findMatches, step over a surrogate pair when either flag is set:re.unicode || re.unicodeSets. - In
compileRegex, rejectuandvtogether with a message about the flags. Today that reachesnew RegExpand comes back as "Invalid pattern: Invalid flags supplied to RegExp constructor 'uv'". - Add
vto the FAQ inlib/tools.ts(line 717) that lists the flags.
Where to look
lib/regex-utils.ts:compileRegex(line 16) andfindMatches(line 30)lib/__tests__/regex-utils.test.ts, next to theuflag test (line 53)app/(tools)/regex-tester/RegexTesterClient.tsxandRegexTesterClient.test.tsx
Acceptance criteria
- Every row in the table gives the expected matches
- There's a
vbutton witharia-pressedlike the others, and turning onuorvturns the other off -
compileRegex("a", "uv")returns an error about the flags - Tests that fail on the current code
-
npm run lint,npm run testandnpm run buildpass
How to test
The table rows go straight into regex-utils.test.ts. For the button, a component test can click u, then v, and check aria-pressed on both. By hand: npm run dev, open /regex-tester, enter the pattern x*, turn on v and paste 😀😀 as the test text. Before the fix it says "More than 1,000 matches, showing the first 1,000"; after it, 3 matches.
Want to work on this? Comment below and I'll assign it to you. Please take one issue at a time, branch off develop, and open your PR against develop with Closes #491 in the description.
- 主要语言
- TypeScript
- 星标
- 1
- 派生
- 9
- 平均合并
- 1 天 8 小时
- 30 天内合并 PR
- 49
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
codercops/toolbelt 的其他 Issue
-
UUID inspector: decode the timestamp, clock sequence and node of v6 UUIDs可能重新可做 @joshuaallgaier2-cmd 于 16 天前认领,目前没有进行中的 PR。 未关闭enhancement good first issue
难度 3/5 半天 新手友好度 82/100
codercops/toolbelt#495 · 2 条评论 ·
维护者通常 1 天内回复
-
Number base converter: show what a hex or binary bit pattern means as a signed integer (`0xFFFFFFFF` is -1 in 32 bits)可能已有人在做 @bhushan4work 于 8 天前认领。 未关闭enhancement good first issue
难度 3/5 半天 新手友好度 82/100
codercops/toolbelt#494 · 2 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 1/100
codercops/toolbelt#101 · 24 条评论 ·
维护者通常 1 天内回复
-
[admin] Quarterly content-refresh routine可能重新可做 @anurag629 于 147 天前认领,目前没有进行中的 PR。 未关闭admin-only seo
codercops/toolbelt#47 · 已指派 1 人 ·
维护者通常 1 天内回复
-
[admin] Repurpose guides to dev communities and social可能重新可做 @anurag629 于 147 天前认领,目前没有进行中的 PR。 未关闭admin-only seo
codercops/toolbelt#44 · 已指派 1 人 ·
维护者通常 1 天内回复
查看 codercops/toolbelt 的全部 Issue
相似的 Issue
-
clawsweeper:intake:bug clawsweeper:intake:needs-environment
难度 2/5 1-3 小时 新手友好度 82/100
openclaw/openclaw#212827 · 1 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
KT-2245 e2e specs that call the backend directly fall back to the developer's own Kronn on :3140未关闭
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
Use one constant for the 10,000-character input limit可能已有人在做 @NginxL 今天认领。 未关闭good first issue refactor
难度 2/5 1-3 小时 新手友好度 78/100
aniru-dh21/snap-validate#51 ·
维护者通常 1 天内回复
-
dependencies effort: small good first issue priority: low
难度 1/5 1-3 小时 新手友好度 88/100
TMHSDigital/screencast-mcp#509 ·
维护者通常 1 天内回复
-
from-review tech-debt testing
难度 2/5 1-3 小时 新手友好度 82/100
blamechris/chroxy#9520 ·
维护者通常 1 天内回复