I am building a program that would simplify coding discord bots. I wanted to add inline functions, but seems like my regex selector is not the perfect match.
My program loops through every inline function and tests if it exists in the string. And replaces the inline function strings with the inline function returnings.
For example, {ping} is translated to 91. Or, {id author} is translated to id of the message author.
The problem is that if there are inline functions in an inline function. I managed to solve 1 inline function per 1, but as the number grow, my regex selector fails and just matches the wrong stuff.
what i want it to match:
{avatarurl {id {message}}}
^^^^^^^^^^^^^^
can even match this too:
{avatarurl {id {message}}}
^^^^^^^^^
this too:
{avatarurl {id {message}}}
^^^^^^^^^^^^^^^^^^^^^^^^^^
and so on.
it just needs to starts from {(function name) and end with }.
my regex selector fails at matching this part, it just matches extra brackets. I need a perfect regex selector that will match {blabla}, but still work when placed into another {blabla}.
this is the pattern that didnt work out: new RegExp(`\{${func.name}([^\}]+[^])*\}`)
the func.name is the function name. i also need the part that comes after "{funcname" and before "}".