Is default word boundary borked, or I'm using it wrong? Default algorithm is supposed to be smarter than simple 1
let rx1 = #/\b\w|\w\b/#
let rx2 = rx1.wordBoundaryKind(.default)
let rx3 = rx1.wordBoundaryKind(.simple)
let text = "abc d ef ghi jklm nop'qrs tuv-wxyz"
print(text)
print(text.replacing(rx1, with: "_"))
print(text.replacing(rx2, with: "_"))
print(text.replacing(rx3, with: "_"))
Everything is a word boundary under default
:
abc d ef ghi jklm nop'qrs tuv-wxyz
___ _ __ ___ ____ ___'qr_ ___-____
___ _ __ ___ ____ ___'qr_ ___-____
_b_ _ __ _h_ _kl_ _o_'_r_ _u_-_xy_
% swift -v
Apple Swift version 6.0.2 (swiftlang-6.0.2.1.2 clang-1600.0.26.4)
Target: arm64-apple-macosx14.0