Regular expression for a string that does not start with a sequence

Regex

Regex Problem Overview


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.

Regex Solutions


Solution 1 - Regex

You could use a negative look-ahead assertion:

^(?!tbd_).+

Or a negative look-behind assertion:

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

Or just plain old character sets and alternations:

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionechoblazeView Question on Stackoverflow
Solution 1 - RegexGumboView Answer on Stackoverflow