EDIT: Fixed the comment match, thanks TheFiddler
Well, you could use something like (the not entirely beautiful);
<!DOCTYPE[^>[]*(\[[^]]*\])?>
It matches a <!
and everything up to a >
or [
, followed by an optional section surrounded by []
, followed by a final >
.
More detail;
<!DOCTYPE -- matches the string <!DOCTYPE
[^>[]* -- matches anything up to a > or [
(\[[^]]*\])? -- matches an optional section surrounded by []
> -- matches the string >