A regular expression replacing directory structure to increase directory

Time:2021-5-3

The following operations need to be solved:
There are multiple shtml files with connection addresses
https://www.jb51.net/fgdf/222/1234.shtml
https://www.jb51.net/tyty/333/456456.shtml
https://www.jb51.net/tyry/789/fsdfsfs.shtml
Now I want to add the directory name Inc to the connection address of these. Shtml files, that is, to
https://www.jb51.net/fgdf/222/inc/1234.shtml
https://www.jb51.net/tyty/333/inc/456456.shtml

Solution: in general, EDITPLUS and other regular expression support software is OK
Find target:

Copy codeThe code is as follows:
^(.+/)(.+)$

Replace with:

Copy codeThe code is as follows:
\1inc/\2

Remember to select “regular expression” on the “find mode” below
By the way, what does the above regular mean,
^(.+/)(.+)$
^Match the beginning of each line
$matches the end of each line
(. + /) matching starts from the beginning of the current line to the last / bracket. Here, it means to capture this group, and then it can be replaced in the front with the content that the regular matches by using the ⁃ 1
(. +) matches the character to the right of the last / in the current line to the end of the line (second capture group)
The whole regular above means to find the last / as the first group from the first character of the current line, and the rest as the second group
Replace with: 1inc / \ 2
The first group matches the content of the second group. Inc / is the character you want in the middle
So together, you can achieve what you want
Namely:
https://www.jb51.net/12/234/678.html
https://www.jb51.net/12/234/ The character that is matched for group one (\ 1)
678. Html is the character matched by group two (\ 2)
And then combined with the content of the replacement, the replacement result is
https://www.jb51.net/12/234/inc/678.html