Saturday 21 December 2019

regex - PHP preg_match any character except word

To match any character except specified character (in this example "f") I use [^f]+.



But how to match any character except specified word? Something like [^word]+




Example:



haystack: "bla1 bla2 bla3 bla4 hello bla5 bla6 bla7" (haystack contains HTML and newlines)



needle: "bla1 bla2 bla3 bla4 "



So I want to catch everything from start untill "hello"

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...