Question about handling/dealing with search patterns as a starting position
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
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
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.*
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.*
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 :)
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 :)
Reply to #2:
Spitze, ich danke Dir :)
Spitze, ich danke Dir :)
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! ;-)
Ich habe meiner ursprünglichen Antwort bereits eine Erklärung hinzugefügt.
Entschuldigung - ich spreche nur Deutsch mit Hilfe von Google Translate! ;-)