Skip to content

Why does regex::Match::end return length + 1? #866

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

You must be logged in to vote

(i know that std::ops::Range stores exclusive, but why should end do the same, when ..= exists?)

Just to nip this part in the bud, the Match API existed long before inclusive range syntax and even std::ops::RangeInclusive itself existed. So this particular aspect of the question starts from the faulty premise that ..= was even a choice at the time the regex API was stabilized.

i have noticed that the function regex::Match::end returns the matches length + 1 and have read here that it is "idomatic", but i am not quite sure why that is, could someone maybe explain?

OK so this is a great question. It's something most people don't think about and is often considered so fundamental that it…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@hasezoey
Comment options

@BurntSushi
Comment options

Answer selected by BurntSushi
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