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 warningone except warning.gif.

I can’t get him to include the last one that has no character (control or other) after it.

using warnings?[^\.]gets what I want, except for the last warning (in the last line). I think because after that there is no character. How can I make it turn on this one?

+3
source share
2 answers

If you have negative images, you can use this:

/warnings?(?!\.gif)/

This should work in Javascript.

+4
source

EDITED

. .

:

, eof.


:

warning here
there are several types of warnings
in this string warning.gif
at the end warning
end of line warning

script:

awk '/warnings?$|warnings?[[:space:]]/ { print }' /home/geocar/g.txt

() :

: /warnings?$/m - , "?" , "s"

+1

Source: https://habr.com/ru/post/1748054/


All Articles