0

I wonder whether SEDE could figure out how many headings (#, ##, ...) a user uses in their answers.

I came up with this query

SELECT  
  Id AS [Answer],
  LEN(Body) AS [Length]
FROM Posts
WHERE PostTypeId=2 AND OwnerUserId=##uid##
AND Body LIKE '%# %'

but it also matches text like C#.

I thought of adding a newline '%\n# %' or '%'+CHAR(10)+'# %' but that just returns no results anymore.

1
  • 5
    The Body appears to be rendered HTML, so you should be looking for <h1> through <h6> elements, not the Markdown for them (which would be incomplete, as they could have been entered as raw HTML in the user input).
    – Makyen Mod
    Sep 4, 2022 at 19:16

1 Answer 1

5

Here is an attempt, which I think avoids <h1> and friends in code blocks (those seem to be stored as <code>&lt;h1&gt;...) – I always forget how those are rendered. Counting headings is simply done by replacing them with empty strings and comparing the resulting string lengths.

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .