Skip to content

regex surface API#3222

Open
hackwaly wants to merge 15 commits intomainfrom
yuxiang/regex-api
Open

regex surface API#3222
hackwaly wants to merge 15 commits intomainfrom
yuxiang/regex-api

Conversation

@hackwaly
Copy link
Contributor

@hackwaly hackwaly commented Feb 12, 2026

Summary

This PR introduces a full surface regex API for both string and bytes, built on top of the existing regex engine and parser infrastructure.

What changed

  • Added compile entrypoints:
    • Regex::new(StringView) -> Regex raise
    • BytesRegex::new(StringView) -> BytesRegex raise
  • Added escaping helpers:
    • Regex::escape(StringView) -> StringView
    • BytesRegex::escape(StringView) -> StringView
  • Added high-level regex operations for both Regex and BytesRegex:
    • find
    • replace_by
    • split
  • Renamed internal package internal/regex_parser to internal/regex_syntax.
  • Added internal/regex_syntax::escape with dedicated tests.
  • Expanded string/bytes README regex sections with syntax coverage, constraints, and runnable examples.

Semantics and notes

  • APIs are marked experimental/internal (subject to change).

Tests

  • Added comprehensive tests for:
    • compile success/failure cases
    • non-capturing and named groups
    • replace/split behavior (including zero-width edge cases)
    • iterator progress/exhaustion for find
    • regex escaping behavior
  • CI stable checks pass across Linux/macOS/Windows.

Open with Devin

@coveralls
Copy link
Collaborator

coveralls commented Feb 12, 2026

Pull Request Test Coverage Report for Build 2638

Details

  • 83 of 91 (91.21%) changed or added relevant lines in 6 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.7%) to 96.711%

Changes Missing Coverage Covered Lines Changed/Added Lines %
bytes/regex.mbt 5 6 83.33%
string/regex.mbt 6 7 85.71%
bytes/regex_methods.mbt 29 32 90.63%
string/regex_methods.mbt 33 36 91.67%
Totals Coverage Status
Change from base Build 2631: 0.7%
Covered Lines: 12086
Relevant Lines: 12497

💛 - Coveralls

@hackwaly hackwaly force-pushed the yuxiang/regex-api branch 3 times, most recently from aeabf96 to ace9749 Compare February 12, 2026 14:44
@hackwaly hackwaly marked this pull request as ready for review February 12, 2026 14:56
@hackwaly hackwaly requested a review from bobzhang February 12, 2026 14:59
Copy link

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

View 6 additional findings in Devin Review.

Open in Devin Review

Copy link

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

View 10 additional findings in Devin Review.

Open in Devin Review

@hackwaly hackwaly marked this pull request as draft February 12, 2026 15:14
@hackwaly hackwaly removed the request for review from bobzhang February 12, 2026 15:14
@hackwaly hackwaly marked this pull request as ready for review February 12, 2026 15:48
@hackwaly hackwaly requested a review from bobzhang February 13, 2026 02:52
@hackwaly hackwaly marked this pull request as draft February 13, 2026 13:45
@hackwaly hackwaly marked this pull request as ready for review February 14, 2026 09:20
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