Let's just talk about the content.
Use RegEx. when using the match () method, you want to match a substring, but the content to be matched may contain line breaks in the resources I load, for example, if the content of my resource is John \ r \ n Smith, I want to match John Smith.
1. vertices (.) in a regular expression (.) represents all characters except \ n, but this is only used outside brackets ([]). If used in brackets, it only represents the dot itself, so this regular expression can be written as "John (. | \ n )*? Smith ".
2. in a regular expression, \ s indicates all blank characters including tabulation (\ t), line feed, and space. \ s indicates all non-blank characters including tabulation, line feed, and space, then the two free combinations can get all the characters, so you can write "John [\ s] *? Smith ",
3. C # RegEx. the match () method receives 3rd parameters. This parameter is a regexoptions enumeration. After my experiment, I found that when I want to match the content of line breaks and carriage returns, set 3rd parameters to regexoptions. singleline. You can write "John. *? Smith ", the same can be matched successfully. So this is also a method. The guess is to enhance the matching effect of the dot number, for example, matching \ n (of course, it is only one kind of guess, you can add an independent \ n to the string, not \ r, and match the result)
Note: parentheses are used in 1, or joined, and brackets are used in 2. Regular Expressions in brackets are automatically selected.
\ R press ENTERCode = 13Return (the mental retardation is to move the cursor to the starting position of the line, that is, the Y coordinate remains unchanged)
\ N line feedCode = 10Newline)
In Windows OS, the Enter key on the keyboard performs the \ r \ n operation, but only the \ n operation in Linux. Therefore, pay attention to this in the code.
Conclusion