We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
You can continue the conversation there. Go to discussion →
"\b"
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"\b" represents word boundaries in regex. But it seems to behave differently in different implementations:
In regex crate, which "can't" was separated
fn main() { let s = "The quick (\"brown\") fox can't jump 32.3 feet, right?"; let re = Regex::new(r"\b").unwrap(); let res = re.split(s).collect::<Vec<&str>>(); // ["", "The", " ", "quick", " (\"", "brown", "\") ", "fox", " ", "can", "'", "t", " ", "jump", " ", "32", ".", "3", " ", "feet", ", ", "right", "?"] println!("{res:?}"); }
in swift 5.7
let s = "The quick (\"brown\") fox can't jump 32.3 feet, right?" let words = s.split(separator: /\b/) // ["The", " ", "quick", " ", "(", "\"", "brown", "\"", ")", " ", "fox", " ", "can\'t", " ", "jump", " ", "32.3", " ", "feet", ",", " ", "right", "?"] print(words) //
In unicode-segmentation crate, it's same as regex in swift, according to the [Unicode Standard Annex #29(http://www.unicode.org/reports/tr29/) rules.
fn main() { let s = "The quick (\"brown\") fox can't jump 32.3 feet, right?"; let res = s.split_word_bounds().collect::<Vec<&str>>(); // ["The", " ", "quick", " ", "(", "\"", "brown", "\"", ")", " ", "fox", " ", "can't", " ", "jump", " ", "32.3", " ", "feet", ",", " ", "right", "?"] println!("{res:?}"); }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
"\b"
represents word boundaries in regex. But it seems to behave differently in different implementations:In regex crate, which "can't" was separated
in swift 5.7
In unicode-segmentation crate, it's same as regex in swift, according to the [Unicode Standard Annex #29(http://www.unicode.org/reports/tr29/) rules.
The text was updated successfully, but these errors were encountered: