I was trying to manipulate a string and needed to find various parts of a string. As an example, the following is the original string:
I wanted to find the part
and replace it with something else, such as
. I also want to change the order of the subfolder that follows the matched part. The end result should be
Note that the original string can also take the form
Also the "20230127.120027" is the time string and can change for different source strings, and the other sub-folder names can also be something else (so
maybe something else such as
). The number of sub-folder levels is also not fixed. The date-time sub-folder is not guaranteed to be staying on a fixed level.
I have trouble capturing the various parts for this operation.
I am using .NET version of regular expressions (namespace
What I have tried:
The regular expression I used is this.
I plan to replace the source string with the following:
However, the second part consumes the rest of the string and it failed to capture the matched_part and the path_to_switch_position. How do I skip to the place that I want to capture?