Kevnuke said:
That's the problem, if i only have one or two herbs in my rift then that won't work. And you lost me at the "'-" part of that pattern O.o Not sure what that does.. but anyway, I'm not sure how hard it would be to just make it so it would Send or parse a script function each time a repeat on same line trigger matched. And if it worked the way i was trying to use it, th wildcards match would be simple, Nick. Just the first and second wildcard for -each- match. Like according to the trigger it would just print the name of the herb and how many of them there were for that herb. Oh and i wouldn't mind if you dissected that pattern for me ^^, looks like a couple backreferences in there, am i right?
Nope! I'll dissect it for you, but first notice that it did match when I only gave it one herb listing. It just filled matches 3 to 6 as 'false', which is perfectly useful as a "hey, this only had one (or two) herb" flag.
The basic 'component' here is this:
\[\s*(\d+)\] ([a-z '-]+?)
This will match, for example, "[ 100] eagle's feather". You have \[\s*(\d+)\] that does that, you should recognize it. Then there's ([a-z '-]+?) , which is a character group being captured. It matches the herb's name, which can have (lowercase) letters, spaces, apostrophes, and dashes. I don't know if any riftables have dashes, but I threw it in there just in case. You know the + at the end, but when it's modified by a ?, it becomes non-greedy. This is so that it doesn't swallow up the trailing spaces that come before the next item in the list.
Lets call that section HERBREX. This doesn't mean anything and you can't use that name in practice, it's just for explanatory purposes here. Replacing the above section with HERBREX in the full regex, it looks like this:
^HERBREX\s*(?:HERBREX\s*(?:HERBREX)?)?$
Now maybe you can see, it matches either one, two, or three HERBREX's. :) |