|
From: Christian S. <sch...@li...> - 2021-09-05 16:48:48
|
On Sonntag, 5. September 2021 15:45:15 CEST Kolja Koch wrote:
> Hi Christian,
>
> cool, thanks a lot for this!
> As far as I understand it, I will be able to use that in my 'gig-
> creator', that I'm working on (by the way, I ended up using wxWidget).
Yes, for now you would probably assemble a command line and call the system()
function to execute the assembled command line, something like:
int res = system("wav2gig --name1-regex '" + name1Pattern + ... );
Later on I will make that available by more convenient functions via the
libgig API. But that's still in the works on my side.
I also slightly changed the default regex patterns, which are now like this:
[^-\/\\]+ - [^-]+ - [^-]+ - [^-]+ - [^.]+
Tearing that pattern down:
[^-\/\\]+
Which means "any sequence of characters except minus ('-'), forward slash
('/') or backslash ('\')". Basically this strips away a leading path like
"/some/where/foo.wav" or "C:\some\where\foo.wav" and stops before the next
" - " delimiter starts.
[^-]+
Any character sequence except minus ('-'). So it stops before the next
" - " delimiter starts.
[^.]+
Any character sequence except dot ('.'). That strips away the trailing
path extension, typically ".wav" or ".WAV".
One more tip: if you are choosing C++ then I recommend to use C++11 string
literals for your regex code. That avoids having to double escape:
// double escaped required (one for regex, one for C++)
string pattern = "[^-\\/\\\\]+";
vs.
// single escape being sufficient (for regex only)
string pattern = R"RegEx([^-\/\\]+)RegEx";
That way you can also directly copy & paste the regex code from your source
code into any RegEx debugging tool of your choice and vice versa.
CU
Christian
|