Implement Lua pattern matching for string functions

Đang mở
#142 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
25/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
go, lua
Lĩnh vực
backend

Hướng nghiên cứu

Start in the string library where findHelper hits the l.assert(false) placeholder, and locate the commented-out match, gsub and gmatch definitions beside it. The work is to port Lua's pattern matching engine so that string.find, string.match, string.gsub and string.gmatch accept patterns. Done means the %s+, (%d+) and %w+ examples in the issue return the expected results, with tests covering both plain and pattern modes.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Currently, Lua pattern matching is not implemented in the string library. This limits the functionality of several string functions to plain text operations only.

Missing Pattern Matching Support

The following functions are either missing or have incomplete pattern matching:

  • string.find - Only supports plain text search, pattern matching raises TODO implement pattern matching
  • string.match - Not implemented (commented out)
  • string.gsub - Not implemented (commented out)
  • string.gmatch - Not implemented (commented out)

Current Implementation

In findHelper, pattern matching is explicitly unimplemented:

} else {
    l.assert(false) // TODO implement pattern matching
}

Use Cases

Pattern matching is essential for:

  • Text processing and validation
  • String transformations (gsub)
  • Data extraction from structured text
  • Cleaning up command output

Example of currently failing code:

-- These would fail with current implementation:
local result = str:gsub("%s+", "")  -- Remove whitespace
local match = str:match("(%d+)")      -- Extract numbers
local iter = str:gmatch("%w+")        -- Word iterator

Impact

This limitation forces users to work around missing functionality with manual string manipulation, reducing the utility of go-lua for text processing applications.

Would it be possible to implement Lua's standard pattern matching engine for these string functions?

Ngôn ngữ chính
Go
Star
3.5k
Fork
217
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Shopify/go-lua

Tất cả issue của Shopify/go-lua

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.