What is the regex to match any title case strings but only in markdown headings (starting with #
?
This regex matches all title case words:
(\b[A-Z][a-z]+)
Unfortunately also outside heading in normal sentences.
Sample matches (bold):
FirstWordInHeading another Word
test Sentence. Test sentence
This regex only matches the first word in a heading but not the others:
(?:^#+\s)(\b[A-Z][a-z]+)
Sample match:
FirstWordInHeading
I'd like to match also any other title case word. In this case, also the string "Word" from the first example.