regex for not matching
I have 开发者_StackOverflow中文版several strings like this
+My_name
My_other_name
+Someone
Otherone
Whats the regex to write to get me all strings that do not begin with the + symbol
I need the result to include
My_other_name
OtherOne
The simplest is probably:
^[^+].*
Working example: http://rubular.com/r/zzNeuvqKFB
You can drop the .*
if you grep
the file anyway.
Of course, all programming languages should have a better way of getting these lines. Even grep has the -v
flag, to negate the pattern.
Try this:
^[^\+].+$
- ^ = Anchor beginning of line
- [^\+] = exclude lines beginning with the plus, and is escaped with a slash so not to confuse the regex.
- . = any character
- = repeat any number of times
- $ = Anchor end of line.
Depends a bit on what program you are using, but something like ^[^+]+
.
精彩评论