Notepad++'s UDL system does not accept regexp.
Thus the UDL system as designed cannot differentiate between a # at the beginning of the line and one in the middle of the line for delimiters and operators. That is a limitation of the UDL system. But if you look at the Markdown (preinstalled) UDL that ships with Notepad++ (which you could be using, rather than defining your own, BTW), it uses the Comment line style for headers, and the Comment Line can require that the comment line only start at the beginning of the line, or only at the beginning of the line (with optional whitespace). So by using Comment Line instead of Operator or Delimiter, it should work as expected.
8d9eed58-d3ad-4d9c-b0d9-81d0ee6a749f-image.png
If that’s not sufficient, but you are willing to use a plugin to help things out, the EnhanceAnyLexer plugin will allow adding a layer where a regex is used to decide on the foreground color for individual built-in lexers or UDL languages. You can install that plugin from the Plugins Admin interface in Notepad++. To use that plugin, you would define your UDL without defining # for headers; then you would use Plugins > EnhanceAnyLexer > Enhance Current Language, and then add a line in the config file where the plugin started you, something like
0x0080FF = ^\h*#.*$… which would convert the entire line to orange foreground if it starts with zero or more spaces or tabs followed by a #