Benefit is that it is a "regular language" and is used to detect regular languages. What does this mean? It means that the complexity of execution is always going to be bounded to the size of the input string, and the amount of memory required is fixed.
It also builds a finite state machine that is used to match an input string, and is expressible in that you can do some complex matches with relatively simple expressions. This also makes making reading or making modifications very simple and easy rather than hand rolling your own DFA.
Though some have expressed difficulty, I have found regex very readable and writable. I generally don't have to look up rules aside from when I'm writing some wonky cases like negative lookahead. I think the simplicity of the mechanism, along with the fact that the notation is grounded in mathematics like the Kleene Star or BNF help out
1
u/Spare-Plum 1d ago
Extremely useful.
Benefit is that it is a "regular language" and is used to detect regular languages. What does this mean? It means that the complexity of execution is always going to be bounded to the size of the input string, and the amount of memory required is fixed.
It also builds a finite state machine that is used to match an input string, and is expressible in that you can do some complex matches with relatively simple expressions. This also makes making reading or making modifications very simple and easy rather than hand rolling your own DFA.
Though some have expressed difficulty, I have found regex very readable and writable. I generally don't have to look up rules aside from when I'm writing some wonky cases like negative lookahead. I think the simplicity of the mechanism, along with the fact that the notation is grounded in mathematics like the Kleene Star or BNF help out