#11 2009-01-11 11:27

krtek
Senior Member
From: Łódź (Poland)
Registered: 2008-02-21
Posts: 262

Re: Examples of Regular Expressions

First of all, I've changed a bit my post above and in the explanation below I will stick to the simplest expression described there - wihout first pair of brackets.
So we have: "^\D+(\d)" -> "$1"
instead of: "^(\D+)(\d)" -> "$2"

eR@SeR wrote:

When we want to limit the action until somewhere we use brackets ("(\d)") and point to the last reference, in this case "$2"?

It depends on what "action" is.
Generally speaking, we use brackets when we need to repeat that particular part of expression in Replace part. Brackets are like saying: "Remember this string. I will quote it in Replace part."
So, if the "action" is to omit anything that were before your delimiter (first digit in that case), you can think about brackets as some kind of marking point.
But to be precize it works that way. In expression you write a pattern of the beginning of your filename, eg.
^\D+(\d), which you can read as "find something that begins at the very beginning of the filename ("^") and consist of  as many as you want, but at least one ("+") non-digits ("\D") followed by a single digit ("\d"), and remember that digit (brackets around "\d").
Then you write Replace part in wich you're simply quoting remembered digit: "$1".
So you are replacing a string that matches your pattern (eg. "blabla4" from filename "blabla4you.mp3") with remembered digit ("4"). So for that particular filename "blabla4you.mp3" it works like simple replace "blabla4" -> "4".
The magic is that for filename "not4you.mp3" a string "not4" will be found and replaced with "4".


eR@SeR wrote:

Well, you missed one, but I didn't forget that since august. Here is Removing a simbol at last position.

Ooops... I was (to be honest I still AM) so busy with arranging my life back in motherland, that I've forgotten about it. No promises, but I will try to find some spare time for that. But I have no idea when wink

Last edited by krtek (2009-01-11 11:40)


Regular Expressions are not as hard to understand as you may think. Check ReNamer's manual or nice Regular Expressions tutorial for more info and start to use full power of applications that use them (like ReNamer, Mp3Tag and so on).

Offline

#12 2009-01-14 01:56

eR@SeR
Senior Member
From: Земун, Србија
Registered: 2008-01-23
Posts: 353

Re: Examples of Regular Expressions

But to be precize it works that way. In expression you write a pattern of the beginning of your filename, eg.
^\D+(\d), which you can read as "find something that begins at the very beginning of the filename ("^") and consist of  as many as you want, but at least one ("+") non-digits ("\D") followed by a single digit ("\d"), and remember that digit (brackets around "\d").

It's more clear now, thank you. This bolded sentence is important and explains:

Generally speaking, we use brackets when we need to repeat that particular part of expression in Replace part. Brackets are like saying: "Remember this string. I will quote it in Replace part."

Ooops... I was (to be honest I still AM) so busy with arranging my life back in motherland, that I've forgotten about it. No promises, but I will try to find some spare time for that. But I have no idea when wink

Like I said... No need for rush wink


TRUTH, FREEDOM, JUSTICE and FATHERLAND are the highest morale values which human is born, lives and dies for!

Offline

#13 2009-05-01 22:14

altech6983
Member
Registered: 2009-05-01
Posts: 3

Re: Examples of Regular Expressions

Hey guys I need help, I can't get this regex to work.

What I have is the file name: Funs 5e04 HDTV 0vt(...).avi

It runs from 5e01 to 5e14

I am trying to arrange it to 5x04 ... I know I can use a regular replace but I don't want to have to change it if it is 4e04 or 3e04 I want it to figure it out by itself.

I am trying to use this pattern:

[\d{1}]e[\d{2}]

and replace with:

$1e$2

but what I get is this:

e1
e2
e3
e4
e5
e6
...

Any help?

Thanks,
Albert

Offline

#14 2009-05-01 22:24

SafetyCar
Senior Member
Registered: 2008-04-28
Posts: 446
Website

Re: Examples of Regular Expressions

Don't use [ ], if you want to remember something you have to use ( )

(\d{1})e(\d{2})

And one other thing, the replacement shouldn't be $1x$2 ?


If this software has helped you, consider getting your pro version. :)

Offline

#15 2009-05-01 23:57

altech6983
Member
Registered: 2009-05-01
Posts: 3

Re: Examples of Regular Expressions

Generally speaking, we use brackets when we need to repeat that particular part of expression in Replace part. Brackets are like saying: "Remember this string. I will quote it in Replace part."

This was what I was following.

Thanks it works now.

That was a typo, I just carried over the e, I really got:

x1
...
thanks for the help

Offline

#16 2009-11-01 12:59

eR@SeR
Senior Member
From: Земун, Србија
Registered: 2008-01-23
Posts: 353

Re: Examples of Regular Expressions

Expression: "- \d\d "     (removes dash blank twoDigits blank)
Replace with: ""             Taken from: Special Rename

Examples:
Bane Opacic Feat. Lexington Band - 2009 - 02 - Da Me Malo Hoce (Voz Snova).mp3
Dzenan Loncarevic - 2009 - 09 - Ko Da Zenu Nikad Nisam Video.mp3
Goes to:
Bane Opacic Feat. Lexington Band - 2009 - Da Me Malo Hoce (Voz Snova).mp3
Dzenan Loncarevic - 2009 - Ko Da Zenu Nikad Nisam Video.mp3

Last edited by eR@SeR (2009-11-01 13:01)


TRUTH, FREEDOM, JUSTICE and FATHERLAND are the highest morale values which human is born, lives and dies for!

Offline

#17 2014-06-16 16:03

asagy
Member
Registered: 2014-06-16
Posts: 1

Re: Examples of Regular Expressions

Forgive the ignorance, but I am new to the program and its power. A simple question; trying to change the order of books in my library, to have author's name before the title. So, here is what I have:

One Nation - Ben Carson.txt

and this is what I would like to have, once rearranged:

Ben Carson - One Nation.txt

Can anyone help plse?

Many thanks, Art

Offline

#18 2014-06-16 19:37

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

Re: Examples of Regular Expressions

Hi Art, welcome.


asagy wrote:

Can anyone help plse?

Yes, use the search and search for "swap" or "hyphen"



    » Swap parts at hyphen
http://www.den4b.com/forum/viewtopic.php?id=1759

    » Swapping Artist and Title on files
http://www.den4b.com/forum/viewtopic.php?id=1033

    » Swap file name
http://www.den4b.com/forum/viewtopic.php?id=931

    » Swap Parts Of The File names
http://www.den4b.com/forum/viewtopic.php?id=192

    » Swap parts and space out words
http://www.den4b.com/forum/viewtopic.php?id=449

    » Swapping words within a file name?
http://www.den4b.com/forum/viewtopic.php?id=145


Search for Rearrange to find even more.

Still unclear?

.


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

Board footer

Powered by FluxBB