Regular Expressions -- Confundling

Posted by Bobo_the_bee on Wed 04 Apr 2007 05:47 PM — 2 posts, 12,479 views.

USA #0
I'm very confused on Regular Expressions, well, the making part of them, that is. I was trying to edit the Health Bar plugin to work with my prompt, which is:

][ Gershaw <4714/4714hp> -- then a bunch of random stuff like money, xp till next level, blah blah blah that I figured could get grouped into one unused variable.

I just can't even begin wondering how I create the regular expression for this. Help on this, or a pointer to a helpfile on making regular expressions, would be very much appreciated.
USA #1
http://www.gammon.com.au/mushclient/regexp.htm and http://www.gammon.com.au/mushclient/funwithtriggers.htm for the help files on regex.

For that first part, it's pretty simple once you understand regex. ^\<(\d+)\/(\d+)hp\>.*
The ^ means this has to start the line off. Anything within () is grabbed as a wildcard. The \d+ means one or more digits. And the .* at the end means anything can follow it (I had to do that, since the whole prompt wasn't posted.

The trigger line on the health_bar plugin should help a decent amount when you compare it to the two help files I listed above. http://www.gammon.com.au/mushclient/plugins/Health_Bar.xml