Reputation: 17118
What regex matches all strings except ones starting with a literal /*
, meaning a slash (U+002F
) followed by a star (U+002A
)?
I’ve tried ^.*[^/\*]
but it doesn’t seem to work for me.
Upvotes: 5
Views: 13892
Reputation: 59451
EDIT: This is for matching strings that starts with a character other than /
and *
- stemmed from misreading the question. Ignore this.
^[^/*].*
^
Beginning of string
[^/*]
Any character other than /
and *
.*
more characters (
Upvotes: 0
Reputation: 22532
^[^/*]
should be all you need:
$ echo -e "*red\n/green\nblue"
*red
/green
blue
$ echo -e "*red\n/green\nblue" | egrep "^[^/*]"
blue
If you definitely need to match lines with at lease two characters you can use ^[^/*].+
Upvotes: -1
Reputation: 36592
that .*
in the beginning is matching anything and everything. You just need to move your not
block to the beginning:
^[^/*].*
Upvotes: 0
Reputation: 39197
You can use a negative lookahead:
^(?!/\*).*
This will match everything except if it starts with /*
.
Or if you mean anything except /
or *
:
^[^/*].*
Upvotes: 12