A regular expression that replaces the directory structure adds an increase to the directory _ regular expression

Source: Internet
Author: User
The following actions need to be resolved:
There are multiple shtml files with connection addresses inside.
Http://www.jb51.net/fgdf/222/1234.shtml
Http://www.jb51.net/tyty/333/456456.shtml
Http://www.jb51.net/tyry/789/fsdfsfs.shtml
Now I'm going to put these. shtml File connection address add a directory name Inc is becoming
Http://www.jb51.net/fgdf/222/inc/1234.shtml
Http://www.jb51.net/tyty/333/inc/456456.shtml

workaround: Generally, editplus and so on support regular expression software can be
Find the target:
Copy Code code as follows:

^(.+/)(.+)$

to be replaced by:
Copy Code code as follows:

\1inc/\2


Remember to select "Regular expression" on the following "Find Mode"
And by the way, what does the above mean?
^(.+/)(.+)$
^ matches the beginning of each line
$ matches the end of each row
(. +/) match from the start of the current line to the last/bracket here to capture the group, and then replace the positive with the inside using \ One to represent what the match is.
(. +) matches the last/right character of the current line to the end of this line (the second capture group \2)
The whole meaning of the above is to find the last one from the first character of the current line. As the first group, the remainder as the second group
To be replaced by: \1inc/\2
The \1 in the above is the content that the first grouping matches to \2 is the content that the second group matches to inc/is the character you want in the middle
So together you can achieve the purpose you want.
That
Http://www.jb51.net/12/234/678.html
http://www.jb51.net/12/234/a match to a group of characters (\1)
678.html matching character for Group Two (\2)
And then replaced with the contents of the inside, the result of the replacement is
Http://www.jb51.net/12/234/inc/678.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.