I'd like to make it possible for someone to copy and paste output from a MUD that I play on into a text box, and then have a php script that will break that output down into manageable chunks and plop it nicely into a database. I'm pretty sure that regular expressions are the way to do it, but I'm not positive. Here's the output (a small portion of it) to be copied:
nexus 43 portal Unknown ( 0%)
(new line)
olos natural selection 80 polymorph Unknown ( 0%)
(new line)
minor watch 15 Unknown ( 0%)
The actual output is much wider, so you don't get the ugly formatting. I inserted the (new line) things myself to clarify.
What we're looking at here is, first off, the spell name. Then a bunch of spaces, then a number which shows the level of the spell. Then a few more spaces and (in some cases) a prerequisite. Not everything has a prerequisite though. Then a few more spaces, one of (Unknown | Novice | Student | Learned | Expert | Master), and then parentheses with a number between 0 and 130 inside, followed by a % sign.
Could anyone help me out with what sort of regular expression I'm going to need? If I can just get each of the seperate parts into their own variables, I can do the rest from there.
Thanks in advance for your help.
Dan