You are not logged in.

#1 2008-06-10 04:57:50

kishd
Member
Registered: 2006-06-14
Posts: 401

Regular Expressions Character Class shortcuts

I have been learning to use regular expressions to modify some of my text files. I noticed that on my ARCH box the Character Class shortcuts do not work e.g. [[:digit:]] in an expression works but \d does not. Is this normal or is my installation broken in some way?


---for there is nothing either good or bad, but only thinking makes it so....
Hamlet, W Shakespeare

Offline

#2 2008-06-10 08:53:39

Procyon
Member
Registered: 2008-05-07
Posts: 1,819

Re: Regular Expressions Character Class shortcuts

I don't see \d in man ed. Maybe \d is for perl regexp only?

Offline

#3 2008-06-10 09:28:16

Bebo
Member
From: Göteborg, Sweden
Registered: 2006-06-07
Posts: 207

Re: Regular Expressions Character Class shortcuts

There are several regexp "dialects". It's quite painful actually tongue For instance, as far as I know, \d works in perl, but not in sed or grep.

So, yes, this is normal.

Last edited by Bebo (2008-06-10 09:29:04)

Offline

#4 2008-06-10 09:48:45

kishd
Member
Registered: 2006-06-14
Posts: 401

Re: Regular Expressions Character Class shortcuts

Thanks bebo.


---for there is nothing either good or bad, but only thinking makes it so....
Hamlet, W Shakespeare

Offline

#5 2008-06-15 14:03:25

ThomasAdam
Member
From: Southampton, England
Registered: 2005-10-26
Posts: 148

Re: Regular Expressions Character Class shortcuts

Bebo wrote:

There are several regexp "dialects". It's quite painful actually tongue For instance, as far as I know, \d works in perl, but not in sed or grep.

So, yes, this is normal.

Yeah -- Henry Spencer's regexp stuff is always generally considered the portable form for sed, awk, since they're all based from it.  Newer versions of grep though do allow for a -P flag for perl-regexps to be used, but this is non-portable, obviously.

-- Thomas Adam

Offline

Board footer

Powered by FluxBB