Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Sources/_StringProcessing/Engine/MEBuiltins.swift
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,9 @@ extension String {
}
case .word:
if isScalarSemantics {
matched = scalar.properties.isAlphabetic && asciiCheck
matched = (scalar.properties.isAlphabetic
|| scalar.properties.numericType != nil
|| scalar == "_") && asciiCheck
} else {
matched = char.isWordCharacter && asciiCheck
}
Expand Down
11 changes: 11 additions & 0 deletions Tests/RegexTests/MatchTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,17 @@ extension RegexTests {
firstMatchTest(
#"(?S)\v"#, input: "\r\n", match: "\r", semanticLevel: .unicodeScalar)

// \w in scalar semantics must match letters, digits, and underscore
// (matching the same definition used in grapheme-cluster semantics),
// not just alphabetics.
matchTest(
#"\w"#,
("a", true),
("1", true),
("_", true),
(" ", false),
semanticLevel: .unicodeScalar)

matchTest(
#"[a]\u0301"#,
("a\u{301}", false),
Expand Down
Loading