Closed
Description
Describe your feature request
Match (regex::Match) represents a group match and has 4 methods, start, end, range, and as_str. While those methods are sufficient, I think len should be added. The reason simply is that I would prefer to use start + len rather than end, because I can't tell immediately if end refers to the last character or the 1 + the last character (it refers to 1 + the last character).
For instance, if I'm replacing a match m
from original sting original_str
, I would use:
original_str.replace_range(m.start() .. m.start() + m.len(), "foo")
rather than
original_str.replace_range(m.start()..m.end(), "foo")
I'm sure there are other instances where developers would prefer to use a len method, instances that make more sense than mine.