Phpstorm regular match deletes empty lines, comment lines (replace empty lines with empty lines), and phpstorm empty lines
Phpstorm is used to compile php and javascript code. It feels good and comfortable to use.
Sometimes, when reading the source code of the framework, you may want to filter (delete) Comment lines in the source code. It is not scientific to manually delete lines by line.
Of course, we thought of a powerful regExp regular expression. by writing a regular expression, we can find all the comment rows and replace them with null to meet our needs.
1. Press ctrl + F and enter the regular expression:(//.*$)|(/*(.|s)*?*/)
2. ctrl + R, without entering:
3. Click Replace all.
However, we found that this did not fully implement our needs, but simply replaced the comment line with a blank line.
Therefore, let's write another regular expression to match and delete empty rows.
1. Press ctrl + F and enter the regular expression:^n
2. ctrl + R, do not enter
3. Click Replace all.
However, it was found that empty rows were not all deleted. (Some blank lines are not deleted)
Therefore, we will continue to delete a regular expression matching.
1. Press ctrl + F and enter the regular expression:sn
2. ctrl + R, do not enter
3. Click Replace all.
Okay. Here, all empty rows are deleted. Have fun -:)
Tips for using regular expressions to delete empty PHP code in phpstorm
Many friends may encounter a lot of empty lines in the code, but it is annoying to delete one line and one line. In this case, batch Delete empty lines is required.
How can I batch Delete empty rows?
My solution is to use regular expressions to locate all blank rows and replace them with one click.
First, check the Match Case and Regex.
Enter the regular rules in the first search box:^\n
After all blank rows are matched, click Replace all.
The replacement effect is as follows:
In fact, these three steps can be combined and implemented in one step. You can think about it!