In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces "delete blank lines and comment lines using phpstorm regular matching". In daily operation, I believe many people have doubts about deleting blank lines and comment lines using phpstorm regular matching. Xiaobian consulted all kinds of data and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts of "delete blank lines and comment lines using phpstorm regular matching". Next, please follow the editor to study!
Encountered a requirement, sometimes when reading the framework source code, want to filter (delete) the comment lines in the source code, if the manual line-by-line deletion display is not scientific.
Of course, think of the powerful regular matching (regExp regular expression), by writing a regular expression to find all the comment lines and replace them with empty, that is, the requirements are implemented.
1. Ctrl + F, enter the regular expression: (/ /. * $) | (/ * (. | s) *? * /)
2. Ctrl + R, do not enter:
3. Click the Replace all at the back
However, it turns out that this does not fully implement our requirements, but simply replaces the comment line with a blank line.
So, let's write another regular expression to match the blank lines and delete them.
1.ctrl + F, enter regular expression: ^ n
2.ctrl + R, do not enter
3. Click the Replace all at the back
However, it is found that the blank lines have not been deleted. (some blank lines have not been deleted)
So, let's move on to a regular matching deletion.
1.ctrl + F, enter regular expression: sn
2.ctrl + R, do not enter
3. Click the Replace all at the back
OK, at this point, all blank lines are deleted. Have fun -:)
Tips for phpstorm to regularly delete blank lines from PHP code
Many friends will encounter a lot of blank lines of code, but it must be annoying to delete a line, so you need to delete blank lines in bulk.
How to delete blank lines in batches?
My way is to find all the blank lines with the rule and replace them all with one click.
First, tick Match Case and Regex
Fill in the regular rule in the first search box: ^\ n
After matching all the blank lines, click [Replace all].
The replacement effect is as follows:
In fact, these three steps should be realized in one step, you can think about it!
At this point, the study on "using phpstorm regular matching to delete blank lines and comment lines" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.