#1 : 24/07-22 17:08
I have files with version in final of the names, ex:
I need to modify all initial text in a List Replace using wildcard (*) and keeping version unchanged.
Ex (animation*...*-4.3.5.zip / magazine-*...*-1.2.3.zip ):
24/07-22 17:08 - edited 24/07-22 17:13
#2 : 24/07-22 18:29
Use a regular expression instead of a simple wildcard.
Use regular expressions
This will replace everything beginning with "animation" up to and including the final instance of "-"
If you always want to keep the initial word then you can use...
In a regular expression "." matches any character and the modifier "*" is an instruction to repeat the match any number of times (including zero).
The meta-character "\K" is an instruction not to include preceding matched characters in the final match.
#3 : 25/07-22 14:51
Reply to #2:
Thank you, man!! It Works !
But in some cases I have versions starting with a point "." instead a "-" eg: animation-school-education-appuniversity.1.2.3.zip
How can I achieve the same result in this situation?
#4 : 25/07-22 16:13
Reply to #3:
Straightforward: Basically use "." instead of "-" as your separating character.
However it's a bit more complicated since you will have to match the first dot in the filename and also dots appear in the version number in all filenames which would lead to unwanted results in other filenames.
The solution is to match "." only if it is followed by a version number. For this we can use a "lookahead" in the regular expression" eg the expression "qwerty(?=uiop)" will match the string "qwerty" but only if it is followed by "uiop" and "uiop" will not be included in the final match.
will replace "animation-education.1.2.3" with "animation-school-education-appuniversity.1.2.3"
Note that "." in a regular expression indicates any character, so it has to be "escaped" as "\." in order to represent itself.
You can handle cases with either "." or "-" in a single expression as follows...
Here the expression [abcd] will match any character appearing in the brackets and placing the expression in parenthesis (ie "([-\.])") will save the result in a numbered variable (\1), which can be used in the replacement string.
25/07-22 16:13 - edited 25/07-22 16:35