Excluding strings using regex

一曲冷凌霜 提交于 2019-11-29 16:44:22
^(?:(?!time|hour|minute).)*$

| is alternation. This means that at all points in the string, we are not looking at any of those expressions (time, hour, or minute). [] is wrong because that creates a character class.

So it means, not looking at (a t, i, m, or e), then (a h, o, u, or r), etc.

I'm going to take a different approach here: what's wrong with !/time|hour|minute/? excessive use of regex is usually a bad idea.

From reading your question, I am guessing you only want "lines" that do not contain the words "time", "hour", or "minute". Try something like...

^(?!.*(time|hour|minute).*).*$
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!