"Junyu Zhang" <24*6*1*
2@s*u*e*t*u*a*e*u*a*> wrote:
> While 'sed -E' and 'grep -E' support the extended regular expressions (ERE), which is the RE syntax of awk, any reasons why we stick to the basic regular expressions (BRE)?
>
> Firstly, 'buy 1 get 3' is appealing because the ERE syntax works in these commands, reducing the cognitive load when learning and using.
>
> Secondly, regarding the portability, I do not have a clue about the targeted operating system or whether we will log in to an ancient machine. Since in Ubuntu 23.04, those commands support the ERE, I think it should run well on other UNIX-like systems having software updated.
>
> Thirdly, the BRE is a little counter-intuitive. For example, some meta characters like '?', and '+' have to be backslashed to become quantifiers, but '*' does not have to. Someone who has not read the manual may fall into this pitfall, not understanding what goes wrong.
Hi Junyu,
Fair question. The answer is that there, once again, a proliferation of RE sub-languages, so in the same way that the course standardised on Bash (which I don't actually use, preferring ksh), the rationale has all along been to go with the systems/tools that are most widely used and supported across a range of Unix/Linux variants. Portability is the key. Hence I aim to teach (and write) algorithmically efficient, but otherwise vanilla code.
The other reason is pedagogic. While some people in the class have come to the unit with loads of experience, many (I suspect the vast majority) have little prior experience and find REs intimidating. One of the things you discover as a lecturer is that you have to teach the class where they are, not where you are. (To be utterly honest, even then I think I was pushing it for many in the class.)
So, old school. Yup!
Good luck in the exams!
Cheers
MichaelW
👨🎨