-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Proposed API:
// Regex literals
pattern = /\d{3}-\d{4}/
// Match operations
phone = "555-1234"
phone.match(/\d{3}-\d{4}/) // Returns match object or nil
phone.match?(/\d{3}/) // Returns boolean
// Replace with patterns
text = "Hello 123 World 456"
text.gsub(/\d+/, "X") // "Hello X World X"
text.sub(/\d+/, "X") // "Hello X World 456" (first only)
// Split with patterns
"a1b2c3".split(/\d/) // ["a", "b", "c"]
// Scan for all matches
"abc 123 def 456".scan(/\d+/) // ["123", "456"]
// Capture groups
match = "2024-01-17".match(/(\d{4})-(\d{2})-(\d{2})/)
match[1] // "2024"
match[2] // "01"
match[3] // "17"
// Match operator
if phone =~ /\d{3}-\d{4}/
puts("Valid phone")
endReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request