Skip to content

#26: fix to_gpt regex to strip space before punctuation#36

Open
VasilevNStas wants to merge 2 commits into
zerocracy:masterfrom
VasilevNStas:26
Open

#26: fix to_gpt regex to strip space before punctuation#36
VasilevNStas wants to merge 2 commits into
zerocracy:masterfrom
VasilevNStas:26

Conversation

@VasilevNStas

@VasilevNStas VasilevNStas commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Problem:
The regex alternation (\\?|!|\\|,|:) in to_gpt() uses \\|, which matches the two-character sequence |,, not a bare comma. Space before a comma is never removed.

Solution:
Replace alternation with character class ([?!,:]). This correctly strips a space before any of ?, !, ,, :. Added regression test removes spaces before punctuation.

Checklist:

  • npx eslint . — 0 errors
  • npx jest --coverage — all pass, coverage >=90%
  • npx tsc --target es2020 --module nodenext --outDir dist — 0 errors
  • make — lint + test + it + tsc pass

@VasilevNStas

Copy link
Copy Markdown
Contributor Author

@yegor256 @edmoffo please review

@kreinba kreinba left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Character class [?!,:] replaces the alternation that contained an erroneous escaped pipe before the comma, so a space before any of the four punctuation marks is now stripped. Regression test exercises all four marks, jest and eslint pass locally. Resolves #26. 0 inline comments.

@VasilevNStas

Copy link
Copy Markdown
Contributor Author

@yegor256 @edmoffo please re-review

@VasilevNStas VasilevNStas changed the title #26: fix to_gpt regex to strip space before commas fix to_gpt regex to strip space before punctuation Jun 7, 2026
@VasilevNStas VasilevNStas changed the title fix to_gpt regex to strip space before punctuation #26: fix to_gpt regex to strip space before punctuation Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants