I am trying to make some sort of Lexer in Java using regex for a custom markdown "language" I'm making, it's my first time working with this stuff so a little lost on a few things.
An example of a possible syntax in it is:
Some <#000000>*text* [<#ffffff>Some more](action: Other <#gradient>text) and **finally** some more <#000>text!
I was able to capture a few things, for example I'm using (?<hex><#\w+>) to capture the "hex" and (?<action>\[[^]]*]\([^]]*\)) to get the entire "action" block.
My problem is being able to capture it all together, like, how to combine it all. For example the lexer needs to output something like:
TEXT - Some
HEX - <#000000>
TEXT - *text*
ACTION - [<#ffffff>Some more](action: Other <#gradient>text)
TEXT - and **finally** some more
HEX - <#000>
TEXT - text!
I'll handle the bold and italic later.
Would love just some suggestions on how to combine all of them!
^(.*?) (?<hex1><#\w+>)(\*[^*]*\*) (?<action>\[[^]]*]\([^]]*\)) (.*?) (?<hex2><#\w+>)(.*)$regex101.com/r/iocBCR/1(?<hex><#\w+>)|(?<action>\[[^]]*]\([^]]*\))|(?<text>[\w!* ]+)regex101.com/r/JWHNP9/1