Skip to content

Splitting text line by line #902

Answered by BurntSushi
bobi6666 asked this question in Q&A
Discussion options

You must be logged in to vote

$ only matches at the end of a string. It sounds like you want it to match at line endings too. You need to enable multi line mode for that, just like you have to do in most other regex engines.

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=3e4ac6e8bf10babeb8937d5c333134e3

Note also that the only recognized line ending is \n currently. There is an issue somewhere tracking the addition of \r\n.

Replies: 6 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by BurntSushi
Comment options

You must be logged in to vote
1 reply
@BurntSushi
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants