I'm doing a Markdown parser as part of a regular expression study, and I'd like to use the amount of characters in a stretch of the expression as a basis for string substitution, for example:
# Titulo
## Titulo
The first title will be added an H1 because I have only one #, the second will be added an H2 since I have two #.
And I would like to use the amount of characters in the snippet that finds regular expression # to replace a string, for example:
markdown.replace(/(\#+) *(.+)/ig, "<h?>$2</h?>");
Where? would be the amount of # found by the expression.
My text is a bit confusing, but this was the best way I found to explain the situation.