How to debug a failing regex-based action?

I have a regex-based replace/match action that does nothing when I try to run it, and I'm presuming I've coded the regex incorrectly. How do people normally diagnose this sort of thing?

I have some podcasts whose titles have contents like:

BAL Dvorak New World Symphony LEN=46:30 FNM=bal_20090502-1030a

I thought I'd try to match parts of that text as follows:

BAL Dvorak New World Symphony LEN=46:30 FNM=bal_20090502-1030a

ie part 1 first word eg "BAL"

       2    following space                         eg " "
       3    text between part2 and part4     eg "Dvorak New World Symphony"
       4    " LEN="
       5    text between parts 4 and 6        eg "46:30"
       6    " FNM="
       7    text between parts 6 and 8        eg "bal_"
       8    eight consecutive digits             eg "20090502"
       9    whatever's left

I wrote this regex to do that:

(\w{2,15})(\s{1,3})(.)( LEN=)(.)( FNM=)(.)(\d(8,8))(.)

and told Mp3tag to replace the text with

$1 $8 $5 $3

hoping to get a new title text like:

BAL 20090502 46:30 Dvorak New World Symphony

But instead Mp3tag simply makes no changes to the title text, and issues no error message. I do not know how to work out why.

Try this:

(.?) (.) LEN=(\d\d:\d\d) (.)(\d{8})-(.)

$1 $5 $3 $2

I've tried this

$regexp('BAL Dvorak New World Symphony LEN=46:30 FNM=bal_20090502-1030a','^(\w{2,15})(\s{1,3})(.+?)( LEN=)(.+?)( FNM=)(.+?)(\d{8})(.*)$',#$1#$8#$5#$3#)

and get this

#BAL#20090502#46:30#Dvorak New World Symphony#

... oh, hmm, where did I verify this?
I've used the dialog "Tag-Filename"!


Thanks to both people who replied. I eventually found the problem in my regex - in the part that was meant to match 8 consecutive digits I'd accidentally entered


which should of course have been

(\d{8,8}) or (\d{8}) as suggested above

ie curly brackets around the min/max part, instead of round ones. D'uh!

I used a freeware regex builder/tester application - Expresso from - to get to the bottom of the problem. It allowed me to enter my erroneous regex and the test data and show that the expression did not match the whole line of data. But more to the point it allowed me to test portions of the regex against the test data so I was able to see that the expression was ok up until the error portion. It displayed to me the partial texts that matched each section of the test string, so I could see what $1, $2, $3 etc were actually being set as. I'd recommend this application!