15
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
this post was submitted on 28 Jul 2025
15 points (100.0% liked)
Programming
21903 readers
338 users here now
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Rules
- Follow the programming.dev instance rules
- Keep content related to programming in some way
- If you're posting long videos try to add in some form of tldr for those who don't want to watch videos
Wormhole
Follow the wormhole through a path of communities !webdev@programming.dev
founded 2 years ago
MODERATORS
But contrary to that, often '0' is also used as the last element or points to "the entire match" in example. Whatever that is. I feel like outside of programming languages, for the end user, its not that clear of an answer. Why I created this topic.
I'll read the linked article and rethink this topic. Maybe introducing another option to make the index 0 based (or the other way 1 based).
Where? I've literally never heard of this convention.
RegExes. For instance, in JavaScript,
'foobar'.match(/(foo)(bar)/)
is['foobar', 'foo', 'bar']
Now that you ask, I don't have any example of this. I know program
head
has negative numbers to access from the last element backwardsls -1 | head -n -1
, but it does not start by 0. So yeah, the 0 as last element might be not as common as I thought to be.-1 is common. I've at least seen it from python.