#1 2016-02-26 18:03

Elektro
Senior Member
Registered: 2014-05-28
Posts: 76

RegexCon - A tool to support RegEx feature lack in Renamer's editor...

12ca0340-dca3-11e5-9ca7-e1fa344e8dac.png



Hi!

I just decided to develop a simple but efficient tool focused on .Net regex-pattern-syntax to support the lack of functionalities of pascal-script's Regex motor that uses the Renamer's script editor.

This is a command-line tool that serves to perform regex substitutions, simply as that, the usage is very intuitive (you can use the long or short parameter names of the self-explanatory image below).

It evaluates the user-pattern before do nothing, then a error message will be returned and a exit-code of 1, the same if it finds a missing parameter or wrong-syntax.

I wonder if @den4b would like to consider add this free accesory as part of Renamer build (only 100 kb extra), because this really increases the capabilities of pascal-script RegEx!.

The download could be found here:
https://github.com/ElektroStudios/Regex … gexCon.exe

The source-code (written in Vb.Net):
https://github.com/ElektroStudios/RegexCon

The same post/article in another forum but with Spanish information:
http://foro.elhacker.net/net/source_reg … 816.0.html

The help:
bRv2UQN.png

An usage example from Renamer's script-editor:

var
  baseName: string;
  extension: WideString;
  rgxPattern: string;
  rgxReplace: string;
  regexconOutput: String;

begin

  baseName  := WideExtractBaseName(FileName)
  extension := WideExtractFileExt(FileName);

  rgxPattern := '^(?<artist>.+?(?=\s*-\s*))\s*-\s*(?<title>.+?(?=(?:\(?(ft|feat|featuring)\.)|$))\(?(?<feat>(ft|feat|featuring)\.[^()\n]+)?\)?(?<subtitle>.+)?$'
  rgxReplace := '${artist} ${feat} - ${title} ${subtitle}'

  begin // Do the replacement.
    if ExecConsoleApp('"'+ WideExtractFileDir(GetApplicationPath()) + '\RegexCon.exe' +
                      '" /Input="' + baseName +
                      '" /Expression="' + rgxPattern +
                      '" /Substitution="' + rgxReplace +
                      '" /MatchCase=False', regexconOutput) = 0 then
    FileName := regexconOutput + extension;
  end;

end.

Input filenames to test:
1. Black Coast - Trndsttr (Feat. M. Maggie) (Lucian Remix)
2. Black Coast - Trndsttr (Lucian Remix) Feat. M. Maggie
3. Black Coast - Trndsttr Feat. M. Maggie (Lucian Remix)

Resulting filenames:
1. Black Coast Feat. M. Maggie - Trndsttr (Lucian Remix)
2. Black Coast Feat. M. Maggie - Trndsttr (Lucian Remix)
3. Black Coast Feat. M. Maggie - Trndsttr (Lucian Remix)
(not really true, the pattern I used has some logic issue about whitespaces, but is a problem that remains on the pattern itself)

.
..
...
Enjoy it!

PS: Sorry for my bad English.

Last edited by Elektro (2016-02-26 23:44)

Offline

#2 2016-02-27 20:11

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,479

Re: RegexCon - A tool to support RegEx feature lack in Renamer's editor...

Good job!

Be aware that ExecConsoleApp function uses String type for parameters instead of WideString. The down side is that you won't be able to work with full Unicode character set, only the local ANSI code page set.

Offline

Board footer

Powered by FluxBB