#1 2013-09-30 01:42

Enrico65
Member
From: Panama - Panama City
Registered: 2011-05-31
Posts: 32

RegExp and \u \U \l \L...

Dear Denis, many thanks for your exceptionally good renaming software, which keeps on improving year after year!

I bring once again to your attention the noticeable limits of the RegExp engine used in ReNamer.
The absence of \u \U \l \L support (among some other RegExp features) creates quite frequent problems when filtering the filenames, in cases in which the CASE function is not subtle enough to provide the required power.
The presence of the Case-sensitive checkbox helps, but cannot replace in full the lacking filters.
I know that we can face every situation with a Pascal script, but, well...

It is my understanding that introducing a wider RegExp engine might be complex at this stage.
The alternative might be to further improve the power of the CASE rule, introducing some of the features available in the DELETE and in the REPLACE functions, such as:
From-until
Position, delimiter, count
Interpret ?,*,[, .... as wildcards
etc.

Most cordial regards,
                                                                                                                  Enrico.

Offline

#2 2013-09-30 22:17

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

Re: RegExp and \u \U \l \L...

Hi Enrico,

Yes, replacing RegEx engine is something I would try to stay away from unless it would be absolutely necessary.

By the way, a similar idea of extending the functionality of the Case rule has been discussed recently and it looks like a viable option.

Offline

#3 2013-10-01 00:16

Enrico65
Member
From: Panama - Panama City
Registered: 2011-05-31
Posts: 32

Re: RegExp and \u \U \l \L...

Hi Denis
    and thanks for your prompt reply.

I overlooked the post about extending the power of the CASE rule.
I strongly hope it will be placed in the future ReNamer releases.

Once again, thanks and most cordial regards,
                                                                                                     Enrico.

Offline

#4 2013-10-01 10:55

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

Re: RegExp and \u \U \l \L...

Recently I found out that Free Pascal component library uses the same RegEx engine (regexpr.pas) as in ReNamer, except it is slightly modified version to add support for \u \U \l \L flags.

So I got an idea of trying an adaptation of this updated engine and with some minor modifications I was able to integrate it into ReNamer. Preliminary tests show great results, we now have working \u \U \l \L flags. However, this library requires further compatibility testing before it can be used in the mainstream.

I have put together an experimental version of ReNamer for testing:
ReNamer-5.72.4-RegEx-Updated.zip

Please test this version for the following:
* It must behave identically to latest stable release, test against all your RegEx rules.
* Correct behaviour of \u \U \l \L flags.

Offline

#5 2013-10-01 12:15

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: RegExp and \u \U \l \L...

Great news. Thank you very much.


- - -

I guess this should work like:

Changing case in the 'Replace' box of regular expressions rule

Special character          Description

\u                                Converts the next character to uppercase.
\l                                 Converts the next character to lowercase.
\U                                Converts all characters to uppercase until encountering \E.
\L                                Converts all characters to lowercase until encountering \E.
\E                                End \U or \L.


- - -

Test 1

FROM:
ReNamer-5.72.4-RegEx-Updated.zip
Lou Bega - Mambo Nr 5.mp3

TO:
ReNamer-5.72.4-RegEx-UPDATED.zip
Lou Bega - MAMBO NR 5.mp3

USE:
1) RegEx: Replace expression "(.+)-(.+)" with "$1-\U$2" (skip extension)

- - -

Test 2

FROM:
of ReNamer
your RegEx
Free Pascal
Free PASCAL

TO:
of reNamer
your regEx
Free pascal
Free pASCAL

USE:
1) RegEx: Replace expression "(.+) (.+)" with "$1 \l$2" (skip extension)

- - -

Test 3

FROM:
Preliminary tests
show great results
we now have working

TO:
Preliminary TESts
show great RESults
we now have WORking

USE:
1) RegEx: Replace expression "(.+) (.{3})(.+)" with "$1 \U$2$3" (skip extension)

- - -

Test 4

FROM:
Preliminary tests - SHOW great results
we NOW Have - Working Flags

To:
Preliminary tests - SHOW GREAT RESULTS
We now have - WORKING FLAGS

USE:
1) RegEx: Replace expression "(.)(.+) - (.+)" with "\U$1\L$2 - \U$3" (skip extension)

- - -

Works in preview on W764

Last edited by Stefan (2013-10-01 12:41)


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

#6 2013-10-01 19:23

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: RegExp and \u \U \l \L...

Second test works too on W732

- - -

http://www.den4b.com/forum/viewtopic.php?id=1812

BEFORE:
titles title S01E01.ext
Titles s08e20.ext

AFTER:
Titles Titles S01E01.ext
Titles S08E20.ext

USE RULES:
1) Case: Capitalize every word (skip extension)
2) RegEx: Replace expression "s(\d\d)e(\d\d)" with "S$1E$2" (skip extension)


- - -


http://www.den4b.com/forum/viewtopic.php?id=1790


James_Band_007_Der_Abend_stirbt_nie_1_1.03.29_20-15_atv_140_TVOF_XX.mpg.avi
James_Band_007_Der_Abend_stirbt_nie_2_13.03.29_20-15_atv_140_TVOF_XX.mpg.avi
TO:
James Band 007 Der Abend stirbt nie 1.avi
James Band 007 Der Abend stirbt nie 2.avi
USE:
1) RegEx: Replace expression "_\d{1,2}\..+" with "" (skip extension)
2) Replace: Replace all "_" with " " (skip extension)

- - -


http://www.den4b.com/forum/viewtopic.php?id=1783

FROM:
File 01 (720p).mp4
File name 03 (720p).mp4
File name extra 23 05 (720p) 45 text.mp4
TO:
File (720p) 01.mp4
File name (720p) 03.mp4
File name extra 23 (720p) 05 45 text.mp4
USE:
1) RegEx Rule: Replace expression "^(.+)(...)( \(720p\))(.+)?$" with "$1$3$2$4" (skip

extension)


- - -

http://www.den4b.com/forum/viewtopic.php?id=1767

FROM:
99-1010.jpg
99-1011.jpg
TO:
wood-99-1010.jpg
wood-99-1011.jpg
USE:
1) RegEx: Replace expression "\A(\d\d-)" with "wood-$1" (skip extension)


- - -

http://www.den4b.com/forum/viewtopic.php?id=1758

FROM:
Stargate701
Stargate DVDrip 702
Stargate 123 DVDrip 703

TO:
Stargate7x01
Stargate DVDrip 7x02
Stargate 123 DVDrip 7x03

USE:
1) RegEx Rule: Replace expression "(\d)(\d\d)$" with "$1x$2" (skip extension)


- - -

http://www.den4b.com/forum/viewtopic.php?id=1180


FROM:
Ace of Base - everytime it rains - [ACECD 10] - [2000]
TO:
Ace Of Base - Everytime It Rains - [ACECD 10] - [2000]

USE:
1) Case: Capitalize every word (skip extension)
2) RegEx: Replace expression "(\[.+])" with "\U$1" (skip extension)


- - -


http://www.den4b.com/forum/viewtopic.php?pid=5798#p5798


FROM:
John Doe - Text File, The
John Doe - Text File, A
John Doe - Ideal Text File, An

TO:
John Doe - The Text file
John Doe - A Text File
John Doe - An Ideal Text File

USE:
1) RegEx: Replace expression " - ([^-]+), (\w+)$" with " - $2 $1" (skip extension)


- - -


http://www.den4b.com/forum/viewtopic.php?id=1157

FROM:
Sway - Silver And Gold (Feat Akon)
Fat Joe - Make It Rain (Feat Lil Wayne)
Lil Jon And The East Side Boyz - Snap Yo Fingers (Feat Sean Paul)

TO:
Sway (Feat Akon) - Silver And Gold
Fat Joe (Feat Lil Wayne) - Make It Rain
Lil Jon And The East Side Boyz (Feat Sean Paul) - Snap Yo Fingers

USE:
1) RegEx: Replace expression "^(.*?) - (.*)(\(.*?\))$" with "$1 $3 - $2" (skip extension)


- - -


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

#7 2013-10-01 23:10

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

Re: RegExp and \u \U \l \L...

@Stefan Thanks for all the testing!

It looks like it's working as expected and should be ready for Beta release.

Offline

#8 2013-10-02 00:17

Enrico65
Member
From: Panama - Panama City
Registered: 2011-05-31
Posts: 32

Re: RegExp and \u \U \l \L...

Dear Sirs, you know? You are GREAT!

Thanks and most cordial regards,
                                                                                          Enrico.

Last edited by Enrico65 (2013-10-02 00:18)

Offline

#9 2013-10-02 07:41

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: RegExp and \u \U \l \L...

Changing case of the next "part" in the 'Replace' box of regular expressions rule.

A "part" could be just the next literal char, but it makes much more sense working on a backreferences.
A backreference you can capture by using parentheses "(...)" around your regular expression
in the Expression box and refer to this with the "$n" statement in the replace box.



To change the case you can utilize this four modifiers:

Special character          Description

\L                        Convert all following characters to lowercase
\l                        Convert the next character to lowercase.  (that's a lower case L)
\U                        Convert all characters to uppercase
\u                        Convert the next character to uppercase.




This can be used like in this examples:

\L      Converts ALL following characterS to lowercase
FROM:     into ReNamer
TO:        into renamer
USE:    RegEx: Replace expression "(.+) (.+)" with "$1 \L$2" (skip extension)

\l      Converts the NEXT character to lowercase.
FROM:     into ReNamer
TO:        into reNamer
USE:    RegEx: Replace expression "(.+) (.+)" with "$1 \l$2" (skip extension)

\U      Converts ALL following characterS to uppercase
FROM:     into ReNamer
TO:        INTO reNamer
USE:    RegEx: Replace expression "(.+) (.+)" with "\U$1 $2" (skip extension)

\u      Converts the NEXT character to uppercase
FROM:     into ReNamer
TO:        Into reNamer
USE:    RegEx: Replace expression "(.+) (.+)" with "\u$1 $2" (skip extension)



Some Testing:

Convert the last three chars to upper:
FROM:     into ReNamer
TO:        into reNaMER
USE:    RegEx: Replace expression "(.+)(.{3})" with "$1\U$2" (skip extension)

Convert the next literal character (makes not really that much sense)
FROM:     into ReNamer
TO:        into ReNamer Universe
USE:    RegEx: Replace expression "(.+) (.+)" with "$1 $2 \Uuniverse" (skip extension)


Convert the third char to lower:
FROM:
ReNamer
UmBenenner
NеPеименовать
TO:
Renamer
Umbenenner
Nеpеименовать
USE:    RegEx: Replace expression "(..)(.)(.+)" with "$1\l$2$3" (skip extension)


Change case before/after a delimiter like here the hyphen:
FROM:
boogie pimps - sunny.mp3
Grave Digger - Heavy Metal breakdown.mp3
TO:
BOOGIE PIMPS - Sunny.mp3
GRAVE DIGGER - Heavy Metal Breakdown.mp3
USE:
1) Case: Capitalize every word (skip extension)
2) RegEx: Replace expression "(.+) - (.+)" with "\U$1 - $2" (skip extension)


FROM:
boogie pimps - sunny.mp3
Grave Digger - Heavy Metal breakdown.mp3
TO:
Boogie Pimps - SUNNY.mp3
Grave Digger - HEAVY METAL BREAKDOWN.mp3
USE:
1) Case: Capitalize every word (skip extension)
2) RegEx: Replace expression "(.+) - (.+)" with "$1 - \U$2" (skip extension)


Move to new created sub folder:
FROM:
Anthrax - MadHouse.mp3
Black Sabbath - Paranoid.mp3
TO:
.\MADHOUSE\Anthrax - MadHouse.mp3
.\PARANOID\Black Sabbath - Paranoid.mp3
USE:
1) RegEx: Replace expression "(.+) - (.+)" with ".\\\U$2\\$0" (skip extension)


- - -

@Denis,
can you add more own code to provide a "\T"  Title modifier too, which call your "Capitalize Every Word" code?
And maybe, not necessary, but for even more convenient, a "\S" Sentence modifier to utilize "First letter capital"

FROM:
deep purple - black night.mp3
axel rudi pell - nasty reputation (live).mp3
TO:
Deep Purple - BLACK NIGHT.mp3
Axel Rudi Pell - NASTY REPUTATION (LIVE).mp3
Use (proposal only):
"(.+) - (.+)" with "\T$1 - \U$2"

- - -

Last edited by Stefan (2013-10-02 09:53)


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

#10 2013-10-02 21:58

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

Re: RegExp and \u \U \l \L...

Stefan wrote:

can you add more own code to provide a "\T"  Title modifier too, which call your "Capitalize Every Word" code?
And maybe, not necessary, but for even more convenient, a "\S" Sentence modifier to utilize "First letter capital"

I could, but since it's a third party component I would want to keep the amount of custom changes to the minimum in order to make future upgrades easier.

Those additional modifiers could be simulated by combining both Case and RegEx rules.

Offline

Board footer

Powered by FluxBB