I want to automatically label examples (as well as remarks, definitions, theorems, etc) based on section number. For example, if I have defined a \section, \subsection or even a \subsubsection environment, I want to be able to automatically label my examples within that section such that I get, taking Section 3.2 for instance, something like
Example 3.2.1 (First example in Section 3.2). This is an example.
Examples 3.2.2 (Second example in Section 3.2). This is another example.
A new example in Section 3.3 would be labelled as
Example 3.3.1 (First example in Section 3.3). Yet another example.
However, I want to also keep denoting the end of the example by some specific character, such as the triangle, as automatically defined in this answer. Any ideas on how to extend this (or other) answer to account for this labelling property and keep the example ending automatic symbol?

\newtheorem{examplex}{Example}[subsection]to get this behavior, but do you have some sections without subsections or some subsections without subsubsections? If so should some of just be "Example 3.1" (if in a section w/o subsections) whereas others are Example "3.2.2" (if in a subsection w/o subsubsection) or "Example 3.1.2.1" (if in a subsubsection), or will they all be the same nesting level? That would make it a little trickier. – frabjous Jul 07 '22 at 13:04