How to skip whitespace when extracting tags from filenames

Hi,

Sorry if this is an obvious question but I've read the FAQ and searched and can't figure this out.

I'm trying to parse tags from filenames / directory hierarchies. Some of the files have the format

%track%-%title%

and some have

%track% - %title%

or other variation of whitespace / no whitespace or even underscores instead of hyphens.

How can I write a Format string that will work for all variations? I'm a software engineer by trade, and I'm not stupid, but the FAQ does not explain how to use $replace scripts at all. It needs some concrete examples.

Thanks,

Alex

Action: Guess Values
Source: $trim($regexp(%filename%,(.*)(-|).,$1))@@@$trim($regexp(%_filename%,.(-|_)(.*),$2))
Formatstring: %track%@@@%title%

here is help for the scripting:
http://help.mp3tag.de/main_scripting.html

and here for the regular expressions:
http://help.mp3tag.de/options_format.html#regexp

EDIT:
i used %artist% instead of %track% because i was reading your question not good enough.
i fixed that now.

This could work ...

Begin Action Group Test 2011#20110112.Guess

Action #1
Actiontype 7: Import tag fields (guess values)
Source format: $regexp(%_FILENAME%,'^ *(.+?)[ _-]+(.+?) *$','$1---$2')
Guessing pattern: %TRACK%---%TITLE%
End Action Group Test 2011#20110112.Guess (1 Action)

.. and this too ...

Begin Action Group Test 2011#20110112.Guess.2

Action #1
Actiontype 7: Import tag fields (guess values)
Source format: $num(%_FILENAME%,1)---$trimLeft(%FILENAME%,'0123456789 -')
Guessing pattern: %TRACK%---%TITLE%
End Action Group Test 2011#20110112.Guess.2 (1 Action)

.. and this too ...

Begin Action Group Test 2011#20110112.FormatValue

Action #1
Actiontype 5: Format value
Field: TRACK
Formatstring: $num(%_FILENAME%,1)

Action #2
Actiontype 5: Format value
Field: TITLE
Formatstring: $trimLeft(%FILENAME%,'0123456789 -')
End Action Group Test 2011#20110112.FormatValue (2 Actions)

DD.20110112.1030.CET
Edit.DD.20110112.1915.CET