不以序列开头的字符串的正则表达式 [英] Regular expression for a string that does not start with a sequence

查看:58
本文介绍了不以序列开头的字符串的正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用这个程序处理一堆表格,但我需要忽略以标签tbd_".到目前为止,我有类似 [^tbd_] 的东西,但根本不匹配这些字符.

I'm processing a bunch of tables using this program, but I need to ignore ones that start with the label "tbd_". So far I have something like [^tbd_] but that simply not match those characters.

推荐答案

你可以使用一个消极的外观-ahead 断言:

You could use a negative look-ahead assertion:

^(?!tbd_).+

或者否定的后视断言:

(^.{1,3}$|^.{4}(?<!tbd_).*)

或者只是简单的旧字符集和替换:

Or just plain old character sets and alternations:

^([^t]|t($|[^b]|b($|[^d]|d($|[^_])))).*

这篇关于不以序列开头的字符串的正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆