Reputation: 10067
So [^x]
means don't match "x", and x*
means match "x" 0 or more times, but what does [^*]
mean?
Upvotes: 24
Views: 4110
Reputation: 11
The search engine symbolhound is a good bet for symbol searches like this. Here are the results for [^*] :
[disclosure: on the SH team]
Upvotes: 1
Reputation: 96557
It means "match a character that isn't a literal asterisk character."
The thing to keep in mind is that within a character class metacharacters don't need to be escaped, so [^*]
is the same as [^\*]
. Similarly, you could use [.]
to refer to a literal dot rather than the metacharacter referring to any character. Outside of a character class you would need to escape it: \.
.
Upvotes: 32
Reputation: 74470
It means a single occurence of a character that is not the actual character *
. No escape character is necessary, because the asterisk has no special meaning inside a character class. This should not be very surprising, since the carat character, ^
, also has a completely different meaning inside a character class.
Upvotes: 5
Reputation: 63590
*
doesn't have special meaning inside a character class, so it means literally "something that's not *
". The only characters that have special meaning inside character classes are -
, ^
and ]
. Other than that everything is taken literally. For example, [^.]
means "something that's not .
", just as [^$]
means "something that's not $
".
Upvotes: 5