#1 : 15/04-22 06:19 Halson William
Posts: 2
|
Hi guys, after searching in these forums and there were no related problems like mine, so i've decided to create a new post.
So i have 1 folder with various filename pattern like this : 01010-81280.xlsx 02782-10210-01_dlb.slsx 7861-93-1930-h01_s20_tmfr-p1.xlsx mp561-61-83211-terrain.xlsx d07088-014a7k28h02-terrain.xlsx tp_01011-81420_d.xlsx i need to clear (-) symbol only at the front with - symbol, so the filename after change will be like this: 0101081280.xlsx 0278210210-01_dlb.slsx 7861931930h01_s20_tmfr-p1.xlsx mp5616183211-terrain.xlsx d07088014a7k28h02-terrain.xlsx tp_0101181420_d.xlsx the - symbol at the end of filename cannot be deleted and stay as the original filename i tried several ways with Replace method but all of - symbol got deleted any suggestion will be much appreciated, thanks |
#2 : 15/04-22 10:37 David Lee
Posts: 1125
|
Your description of the problem does not make sense - it is muddled and does not correspond to all the examples given. You should define the rules that will apply to all possible desired replacements.
However, based only on the examples you have provided, you can achieve the desired results with three Replace methods... (1) Replace: \d\K- with: nothing Occurrence: 1st Use regular expressions Removes the first hyphen following a digit. (2) Replace: -([^-]*-) with: \1 Use regular expressions If there are more than one hyphens remaining in the filename the first one is removed. 3) Repeat method (2) |
#3 : 22/04-22 08:25 Halson William
Posts: 2
|
Reply to #2:
Thanks this method works if i combining with replace method 1 and 2 like you mentioned. Sorry for not clearing up the question and making confuse. |