Home >Backend Development >PHP Tutorial >How to use regular matching to delete blank lines and comment lines in phpstorm
This time I will show you how to use regular matching to delete empty lines and comment lines in phpstorm. What are the precautions for using regular matching to delete empty lines and comment lines in phpstorm. The following is a practical case. Let’s take a look.
I encountered a need. Sometimes when reading the source code of a framework, I want to filter (delete) the comment lines in the source code. If I delete it manually line by line, it will not be scientific enough.
Of course I thought of the powerful regular expression (regExp regular expression). By writing a regular expression, we can find all the comment lines and replace them with empty ones, which is achieved. need.
1. ctrl F , enter the regular expression: (//.*$)|(/*(.|s)*?*/)
2 . ctrl R, do not enter:
3. Click Replace all
but found that this did not fully realize our needs, but only replaced 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 the regular expression: ^n
2.ctrl R, do not enter
3. Click Replace all
But I found that not all blank lines were deleted. (There are still some blank lines that have not been deleted)
So, let’s continue with a regular matching deletion.
1.ctrl F, enter the regular expression: sn
2.ctrl R, do not enter
3. Click Replace all# at the end
##Okay, here, delete all the blank lines. Have fun -:)phpstorm uses regular expressions to delete PHP codeTips for empty lines
Many friends will encounter special empty lines of code There are many, but deleting rows one by one will definitely be annoying. At this time, you need to delete blank rows in batches. How to delete blank lines in batches? My method is to use regular expressions to find all blank lines, and then replace them all with one click. First check Match Case and RegexFill in the regular rules in the first search box:^\n
Summary of the steps to use commas and dots for echo in php
PHP development of WeChat remote control Detailed explanation of server steps
The above is the detailed content of How to use regular matching to delete blank lines and comment lines in phpstorm. For more information, please follow other related articles on the PHP Chinese website!