Regular Expression question

Posted by Jedhi on Wed 30 Jan 2013 03:15 PM — 2 posts, 13,431 views.

#0
Hello,


Absorb                    317    87%             1


i want to trigger the line above and get the skillname(absorb), sn(317) and the %(87) value.

with trial and error i managed to do this. skill name needs to be trimmed. can i optimize this?


match="^(?<skill>[a-zA-Z\s]+)[\s]+(?<sn>[0-9]+)[\s]+(?<learned>[0-9]+)%(.*)$"
Amended on Wed 30 Jan 2013 10:06 PM by Nick Gammon
Australia Forum Administrator #1
Make the skill group less greedy:


<triggers>
  <trigger
   enabled="y"
   match="^(?&lt;skill&gt;[a-zA-Z\s]+?)[\s]+(?&lt;sn&gt;[0-9]+)[\s]+(?&lt;learned&gt;[0-9]+)%(.*)$"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>
print "skill = '%&lt;skill&gt;'"
print "sn = '%&lt;sn&gt;'"
print "learned = '%&lt;learned&gt;'"
</send>
  </trigger>
</triggers>



Template:pasting
For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.