I'm trying to do a custom markdown notation and I need the inner most markdown every time, At the moment I have only 2 markdowns for testing purposes _
and *
Regex:
(?<![_\*])(?<!\\)\*(?![_\*])(([^\*]|\\\*)*)(?<![_\*])(?<!\\)\*
for capturing the inner most *
Examples:
- Should capture:
*test1\*test2*
- Captures! - Should capture:
_*test1\*test2*_
- but doesn't Capture because of the next rule. - Shouldn't capture:
*_test1\*test2_* some random text *
- Doesn't Capture*_test1\*test2_*
and captures* some random text *
but I want to ignore this capture.
If I remove my first look before (?<![_\*])
works for 1 and 2, but captures the last *
from the text until the next one because the beginning *
is from from the previous text which should be ignored