Sorry, I forgot to put the case-insensitivity back in. That's done with the 'i' modifier: /regex/i. The stats were wrong because I was looking for a non-space \S instead of a space \s. I've edited my original post with these fixes.

It pretty much works the same way as the one you provided, with a slightly different regex. I'll explain the parts of it below so you can better understand what's going on.

/((?:spy )?(?:of|de)fen(?:c|s)e):?\s+(\d{1,3}(?:,\d\d\d)*(?:\s|$)|\d+)/gi

((?:spy )?(?:of|de)fen(?:c|s)e) - This part matches (all four) stats. (?:spy )? is optional, and will match the 'spy' text. (?:of|de)fen(?:c|s)e) matches the words offense/offence/defense/defence. The name of the stat is captured here, and used later when writing to the file.

:?\s+ - This matches the optional : after the stat, and the space before the value.

(\d{1,3}(?:,\d\d\d)*(?:\s|$)|\d+) - This matches properly formatted numbers with commas, or numbers with no commas. First it looks for 1 to 3 digits \d{1,3}. Next, it looks for zero or more repetitions of a comma followed by three digits ,\d\d\d. After these digits there needs to be a space or end of line \s|$. If this kind of comma number doesn't match, it tries to match a number without any commas \d+

//gi - 'g' is for global. It will apply the regex continously until it reaches the end of the line. In this way it will go over all four stats, without this, it would stop processing after the first stat is matched. 'i' is for case insensitiviy.

Last edited by Loki12583; 04/07/12 10:21 PM.