Thoughts regular expressions in, for example sed

Johnny Rosenberg gurus.knugum at gmail.com
Sat Jan 12 14:05:00 UTC 2013


2013/1/12 Colin Watson <cjwatson at ubuntu.com>:
> On Fri, Jan 11, 2013 at 11:43:02PM +0100, Johnny Rosenberg wrote:
>> I don't know if regular expressions are used the same way in all those
>> nice tools, like sed, grep and whatever, but I can't stop wondering
>> why the regular expression syntax is so inconsistent.
>>
>> Some characters are used for things, so if I want to search for them I
>> need to escape them, for example ”.\[]{}”, but what about ()? They are
>> the other way around: I have to escape them when I want to use them!
>> Why is this?
>
> If you want a somewhat more consistent syntax, use extended regular
> expressions (e.g. with 'sed -r', which is a GNU sed extension).

Thanks. () still need to be escaped though.

>
> The answer to your question is probably simply that the regular
> expression language used in Unix tools evolved organically over time
> rather than being designed in one go.

Maybe it's time for ”the next version” (total remake) of the whole
concept of regular expressions and give it a few decades.
The old ”version” could then be referred to as ”regular exceptions”…


Johnny Rosenberg

>
> --
> Colin Watson                                       [cjwatson at ubuntu.com]
>
> --
> ubuntu-users mailing list
> ubuntu-users at lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users




More information about the ubuntu-users mailing list