This time I will bring you a detailed explanation of the use of regular expressions and carriage return and line feed characters. What are the precautions for using regular expressions and carriage return and line feed characters? The following is a practical case, let's take a look.
In C#, when reading the content of a text file, there are often many carriage returns and line feeds ("\r\n"). Although they are generally invisible, they actually exist. At this time, when using regular expressions for matching, you need to consider its existence. I encountered such a problem today: There is a text file with the following content:DT 20180101000000 WT -1.1 SL 31.4 WL 203 DT 20180101000000 AT -4.1 BP 1023.7 HU 26 RN 99999.9 WS 1.9 92 2.0 94 3.4 79 2111 4.6 83 2103
regular expression: WT\s (?, the result is that no matching value can be obtained. The reason is that the text content read contains many carriage returns and line feeds "\r\n". For example, in the line WT -1.1, the actual content is
WT -1.1\r\n ". In this case, the line ending character "$" will not work. It should be said that if you directly
read the file content and use regular expression matching, it will not work.
WT\s+(?<WT>.+)\r\n
Under what circumstances are padding and margin of inline elements invalid
Detailed explanation of steps to use JS array method
The above is the detailed content of Detailed explanation of the use of regular expressions and carriage return and line feed characters. For more information, please follow other related articles on the PHP Chinese website!