Why is people using regular expressions to find headers?

After readings many lines of code, both in this forum and in the source code off many plugins I’m more confuse than ever about this fact. At first I thought that, given the nature of this fórum many people were just not familiar with obsidian API or JavaScript. However the same pattern keeps popping in many snippets and the source code of many plugins: people split a file by newlines and then try to guess the headers using regular expressions. Why? Obsidian provides a method to get the structure of a file, detailing headers, bullet lists, etc, which is IMO more reliable for procedural interaction. Does this API have any drawback that I am unaware of?

CachedMetadata.headings is useful if you don’t care that much about how fresh the information is. But sometimes you need to obtain the most up-to-date state of a file, in which case CachedMetadata.headings might be slightly outdated because the indexing process is denounced.

To find headings from the up-to-date file contents, you can use CodeMirror’s syntaxTree but usually it’s just too much, because in markdown headings can be easily located by splitting the text into lines and then looking at the beginning of each line.

That makes sense, thatnks for the explanation.
I wonder why obsidian doesn’t offer the option to parse a specific file to get the same information but up to date