Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试提出一个单一的正则表达式来匹配所有包含“移动”但不包含“视频”的字符串我一直在努力在一个表达式中做到这一点,并希望得到任何帮助。
使用否定的前瞻断言:
^(?!.*video).*mobile
例子:
$ cat 1.txt audio-mobile mobile-video mobile-video video-mobile videomobile mobile audio-mobile audio $ grep -P '^(?!.*video).*mobile' 1.txt audio-mobile mobile audio-mobile