Not sure if this is perfect, but it seems to be working
However, it does not work for multi line delimiters.