regex no character
In this text:
warning here there are several types of warnings in this string warning.gif at the end warning end of line warning
I want to match every warning
except warning.gif
.
I cannot seem to get it to include the last one that has no character (control or otherwise) after it.
usi开发者_JAVA技巧ng warnings?[^\.]
gets what I want except for the last warning (on the last line). I think because there is no character at all after. How can I get it to include that one?
If you have negative lookaheads you can use that:
/warnings?(?!\.gif)/
This should work in Javascript.
EDITED
I completely misread the question. My apologies.
Here's a corrected solution:
Alternatives can bind more tightly than the eof marker.
Example file:
warning here
there are several types of warnings
in this string warning.gif
at the end warning
end of line warning
Example script:
awk '/warnings?$|warnings?[[:space:]]/ { print }' /home/geocar/g.txt
Original (wrong) answer:
Use: /warnings?$/m
- note that the "?" means that the "s" is optional
精彩评论