I'm experimenting with some macros using regex. Currently, I'm working on a macro that will get all the text in GM Notes (where I usually store the original character sheet) and select some parts of it to store them in the properties (DnD 5e). It's working great, until the "Actions" section and beyond, where it's hard to tell the regex where exactly are the Actions, Reactions, Legendary Actions etc.
The idea I'm trying to follow is: find the word "Actions" (positive look behind) and select everything (not greedy) until you find either the words "Reactions, Legendary Actions etc" (positive look ahead). This way, if a sheet is missing some of the actions (like the reactions), the reg ex keep selecting until it finds the next sets of actions and stops. It works, but the problem is that if a character only has the actions and nothing else the regex doesn't match anything.
Code: Select all
(?<=Actions.*\\n\\n)([\\s\\S])+?(?=\\nReactions|\\nLegendary Actions|\\nLair Actions|\\nRegional Effects)
Code: Select all
(?<=Actions.*\\n\\n)([\\s\\S])+?(?=\\nReactions|\\nLegendary Actions|\\nLair Actions|\\nRegional Effects|$)
How can I tell MapTool to match until the next set of actions OR until the end of the sheet if there are no other sets of actions?
EDIT: I thought of a workaround. I can create a new regex that will have to match every set of actions but "Actions". If the count is greater than 0 (aka if there are other sets of actions besides "Actions"), than the macro have to use the Regex I wrote before, otherwise, use the same regex but without the positive look ahead. Have to test it, but it's still a workaround instead of a real solution