Friday 22 November 2019

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



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.



Answer



You could use a negative look-ahead assertion:



^(?!tbd_).+


Or a negative look-behind assertion:



(^.{1,3}$|^.{4}(?



Or just plain old character sets and alternations:



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

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...