|
Repeating on the same line
|
Reply to this subject
Start a new subject
 
Refresh page
| Posted by |
Larkin
(278 posts) bio
|
| Date |
Fri 24 Jun 2005 02:31 PM (UTC) [ quote
] Amended on Fri 24 Jun 2005 02:33 PM (UTC) by Larkin
|
| Message |
I haven't figured out the trick to triggering a pattern multiple times in a single line. I'm attempting to check the contents of my pocketbelts and store the values in a table. I can make three or four triggers or come up with a complex regular expression to do this, so that's not my question. Can anyone tell me how to match on a very simple expression that just repeats on the same line? My trigger isn't doing it.
Sample output to match on:
You check the contents of your 5 pocketbelts:
3959 spices 5 kombu 63 coltsfoot
36 kafe 53 galingale 49 pennyroyal
50 faeleaf 51 calamus 61 marjoram
2 colewort 51 myrtle 120 chervil
50 arnica
My trigger:
<triggers>
<trigger
enabled="y"
keep_evaluating="y"
match="(\d+)\s+(\w+)"
regexp="y"
repeat="y"
send_to="12"
sequence="100"
>
<send>Note("You have %1 of %2.")</send>
</trigger>
</triggers>
My results:
You check the contents of your 5 pocketbelts:
You have 5 of pocketbelts.
3959 spices 5 kombu 63 coltsfoot
You have 3959 of spices.
36 kafe 53 galingale 49 pennyroyal
You have 36 of kafe.
50 faeleaf 51 calamus 61 marjoram
You have 50 of faeleaf.
2 colewort 51 myrtle 120 chervil
You have 2 of colewort.
50 arnica
You have 50 of arnica.
Edit: monospace isn't monospaced? Code is, though. Heh. | top |
|
| Posted by |
Flannel
USA (1,230 posts) bio
|
| Date |
Reply #1 on Fri 24 Jun 2005 06:25 PM (UTC) [ quote
] |
| Message |
Your trigger will MATCH multiple times on a line (turn on highlighting, you'll see), however it will only send to the script (and thus, your note) once per line.
So, you'll have have three triggers (one for three items, one for two items, one for a single item), of course, you could also just have a single trigger with three items in it (where two are optional).
http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=2526
Theres a post in there from Nick with an example of the optional wildcards. |
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | top |
|
| Posted by |
Larkin
(278 posts) bio
|
| Date |
Reply #2 on Fri 24 Jun 2005 07:31 PM (UTC) [ quote
] |
| Message |
Thanks. At least I'm able to get it to match with only one trigger then.
Can anyone (Nick) explain why it only sends to the script once? Other than highlighting or gagging, what's the use in matching multiple times and not executing each time. I mean, I can easily cause stack overflows with infinite loops in other places, so why not here? :) | top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
1,623 views.
Reply to this subject
Start a new subject
 
Refresh page
top
Comments to:
Gammon Software support
Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )