I am got a regular expression in sed, I am not sure ":" stand for anything here.
sed 's/:[^\t]*//g'
Could you please give me some infomation?
Update: I got the command from a publication, I'm confused because if the :
is a normal character, then the [^\t]
following it means the start of the line, which seems to actually match a :
before the start of the line, which doesn't seem to have any effect?
Best.
Zhang.
CodePudding user response:
I'm confused because if the : is a normal character, then the
[^\t]
following it means the start of the line, which seems to actually match a : before the start of the line, which doesn't seem to have any effect?
Normally, ^
means "start of line", that's right.
However, what you're looking at here is a character set. And in that context, the ^
means "negated".
So actually, [^\t]
has got nothing at all do do with "start of line". It means "not a tab". (\t
means "tab character".)
In summary, this regex:
:[^\t]*
means "a literal :
character, followed by any number of non-tab characters".
CodePudding user response:
There is nothing special about :
in regex. It simply matches a :
character.
All special characters are listed in the documentation (that's Python since you tagged with python-re
; the dialect used by sed
is different but also doesn't have a special meaning for :
).