Although I am almost sure this has been covered, I can\'t seem to find anything specific to this. As I continue my journey on learning bash I keep finding parts where I am b
Both expressions are equivalent, the difference is the regular expression you use:
$ echo `expr "$Stext" : '^\(.[a-z]*\)'`
Hallo
$ echo `expr "$Stext" : '^.[a-z]*'`
5
$ echo `expr "$Stext" : '\(.*World\)'`
Hallo World
$ echo `expr "$Stext" : '.*World'`
11
As you can see, parentheses is what makes the difference to either return the length of the match or the match itself.
You can find more examples in Chapter 10 of the Advanced Bash-Scripting Guide.