Question about handling/dealing with search patterns as a starting position

Advanced Renamer forum
#1 : 21/06-22 18:01
Stephan
Stephan
Posts: 3
Hello,

I just can't figure out how to solve the following problem with AR on my own:

For example, I have the following filenames:

Xfcc_ddfff_ddffff_00100330_jknbh_klknd_00998
Drdd_zhgg_efertg_009883_asddff
Hhzfff_nnnn_008787_khhbed_klh_0099_jjjh_llkjj

Now I want to delete everything after the third underscore. However, the file names are of different lengths, i.e. the search criterion is always the third underscore from the front/left (depending on how you count it).

How can I solve this without having to do a lot of programming?

Kind Regards
Steve


21/06-22 18:01
#2 : 21/06-22 18:12
David Lee
David Lee
Posts: 1026
Remove pattern...

Pattern: ^[^_]*_[^_]*_[^_]*_\K.*
Use regular expressions

Explanation...

^ : Start at the beginning of the filename

[^_]*_ : Remove as many non-underscore characters as possible, followed by one underscore - repeat to a total of 3 times.

\K : Exclude everything matched so far from the final match

.* : match everything else

This will leave the 3rd underscore at the end of the filenames. To remove that as well use...
Pattern:^[^_]*_[^_]*_[^_]*\K.*


21/06-22 18:12 - edited 21/06-22 18:17
#3 : 21/06-22 18:15
Stephan
Stephan
Posts: 3
Reply to #2:
Hi David, thanks a lot for your quick answer.

Can you explain the expressions to me? I´ve read the Guide for Regular expressions, but I dont understand the meaning of groups and lists and so on.

Kind regards

Steve

P.S.: Wenn Du Deutsch sprichst, kannst Du mir das gerne auch auf Deutsch erklären :)



21/06-22 18:15
#4 : 21/06-22 18:21
Stephan
Stephan
Posts: 3
Reply to #2:
Spitze, ich danke Dir :)


21/06-22 18:21
#5 : 21/06-22 18:25
David Lee
David Lee
Posts: 1026
Reply to #3:

Ich habe meiner ursprünglichen Antwort bereits eine Erklärung hinzugefügt.

Entschuldigung - ich spreche nur Deutsch mit Hilfe von Google Translate! ;-)


21/06-22 18:25