Hi,
How can I copy file name from each line and paste it at the beginning of the line with regular expression. For example, I have directory file listing as follows:
C:\Users\abcxyz\Documents\Default.rdp
C:\Users\abcxyz\Documents\desktop.ini
C:\Users\abcxyz\Documents\LotusInstall.log
C:\Users\abcxyz\Documents\eFax Messenger 4.4\Fax 1.efx
C:\Users\abcxyz\Documents\eFax Messenger 4.4\Fax 2.efx
C:\Users\abcxyz\Documents\eFax Messenger 4.4\Fax 3.efx
C:\Users\abcxyz\Documents\eFax Messenger 4.4\Fax 4.efx
C:\Users\abcxyz\Documents\eFax Messenger 4.4\faxed.gif
and the new listing should look like this:
Default-C:\Users\abcxyz\Documents\Default.rdp
desktop-C:\Users\abcxyz\Documents\desktop.ini
LotusInstall-C:\Users\abcxyz\Documents\LotusInstall.log
Fax 1-C:\Users\abcxyz\Documents\eFax Messenger 4.4\Fax 1.efx
Fax 2-C:\Users\abcxyz\Documents\eFax Messenger 4.4\Fax 2.efx
Fax 3-C:\Users\abcxyz\Documents\eFax Messenger 4.4\Fax 3.efx
Fax 4-C:\Users\abcxyz\Documents\eFax Messenger 4.4\Fax 4.efx
faxed-C:\Users\abcxyz\Documents\eFax Messenger 4.4\faxed.gif
Basically, I need to copy a string from the last backward slash "\" to the last dot "." and paste at the beginning of each line.
Any insight is really appreciated.
Thanks Guys.
Filename without extension
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
^(.+\\(.+)\.) matchesFind what: ^(.+\\(.+)\.)
Replace with: $2-$1
[X] Regular expression
Code: Select all
^ the beginning of a line
( start of captured text number 1
.+ any non-empty string within a line (see below)
\\ a literal back-slash
( start of captured text number 2
.+ any non-empty string within a line (see below)
) end of captured text number 2
\. a literal dot
) end of captured text number 1
Code: Select all
. any character except newline
+ ... any non-zero number of times
Code: Select all
$2 captured text number 2
- a literal hyphen
$1 captured text number 1
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm