#1 : 31/07-19 20:14 Edward Eade II
Posts: 6
|
What regular expression would i use to rename certain parts of a string while keeping other parts of a string the same
Example Originals: Advanced Theory Session01Class01 Intro Advanced Theory Session02Class02 What have we learned Example final name desired Advanced Theory - session01class01 - Intro Advanced Theory - session02class02 - What have we learned Basically I want to translate the boolean match??match?? to replacement??replacement?? into a regular expression Followup: So far what I have is Find Session(.*)Class(.*) Replace session\1class\2 - Which gets me everything except the 2nd " - " it ends up being placed before the last word for example Advanced Theory - session02class02 What have we - learned |
#2 : 01/08-19 09:48 David Lee
Posts: 1125
|
You have three issues here...
1) Your replace string does not add the first hyphen. 2) (.*) matches as many characters as it can - so the second instance should match all remaining characters in the filename and your second hyphen should be placed at the end of the filename. 3) You must accidentally have added a space to the end of your "Find" string so that the second (.*) will terminate before the final space - ie before the final word. Find: Session(.*)Class(..) will work, but only when the class number is exactly two characters long. Find: Session(\d*)Class(\d*) will be better. |
#3 : 01/08-19 18:53 Edward Eade II
Posts: 6
|
Reply to #2:
That did it, thanks |