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