I have been having a lot of problems creating a multi-line regular expression trigger. The issue surrounds the complicated situation of lines that may or may not be present in the overall expression.
The line: "This item is covered with razor sharp spikes" may or may not be present on any given item. Example:
My expression is as follows (I inserted newlines for ease of viewing):
*Note* The final line was causing me the same problem of double firing, but I found a work around by using "|\s+" because immediately after that line is a blank line. The trigger fires perfectly when the line for the spikes is present. However, if that line is not present it causes the trigger to match two times and I really have no idea why. I also tried "(?:This (item|weapon) ([a-z ]+).\n|\n)?" But it would match twice as well. If that line would only match one of the OR clauses it would be fine, but it matches for both. This project has propelled my regex knowledge quite a ways, however it seems I still have a lot to learn. Any help you guys can offer is greatly appreciated! :D
'king crown unique armor' is type armor, extra: rare
This item needs 150000 gold coins before it can be refined.
Armor class is 205. [+197% Enhanced Defense]
This item is covered with razor sharp spikes.
Affects strength by 5.
Affects intelligence by 5.
Affects wisdom by 5.
Affects dexterity by 25.
Affects constitution by 15.
Affects agility by 5.
This item has 525 points of magical resistance.
The line: "This item is covered with razor sharp spikes" may or may not be present on any given item. Example:
'king crown unique armor' is type armor, extra: rare
This item needs 150000 gold coins before it can be refined.
Armor class is 205. [+197% Enhanced Defense]
Affects strength by 5.
Affects intelligence by 5.
Affects wisdom by 5.
Affects dexterity by 25.
Affects constitution by 15.
Affects agility by 5.
This item has 525 points of magical resistance.
My expression is as follows (I inserted newlines for ease of viewing):
Your eyes glow bright yellow for a moment.\n
'(?:king|grandmaster) (?:[a-z]+) ([a-z]+) [a-z ]+' is type (?:[a-z -]+)?( weapon|armor|light), extra: rare\n
This item needs [0-9]+ gold coins before it can be refined.\n
Armor class is [0-9]+. [[0-9+%]+ Enhanced Defense]\n
(?:This (item|weapon) ([a-z ]+).\n)?
Affects strength by [0-9]+.\n
Affects intelligence by [0-9]+.\n
Affects wisdom by [0-9]+.\n
Affects dexterity by [0-9]+.\n
Affects constitution by [0-9]+.\n
Affects agility by [0-9]+.\n
(?:This item has ([0-9]+) points of magical resistance.|\s+)
*Note* The final line was causing me the same problem of double firing, but I found a work around by using "|\s+" because immediately after that line is a blank line. The trigger fires perfectly when the line for the spikes is present. However, if that line is not present it causes the trigger to match two times and I really have no idea why. I also tried "(?:This (item|weapon) ([a-z ]+).\n|\n)?" But it would match twice as well. If that line would only match one of the OR clauses it would be fine, but it matches for both. This project has propelled my regex knowledge quite a ways, however it seems I still have a lot to learn. Any help you guys can offer is greatly appreciated! :D