Regular expression learning record

Q: What does (?i) (?s) (?m) (?is) (?im) in front of the often seen regular expressions mean?
A: It is called the inline matching mode, which is usually replaced by the global matching mode specified by the enumeration value RegexOptions with the inline matching mode, which is more concise to write.
  (?i) indicates that the expression to the right of the position enables ignore case mode
  (?s) indicates that the expression to the right of the position enables single-line mode.
  Change the meaning of the period character (.) so that it matches every character (instead of all characters except \n).
  Note: (?s) is usually used when matching text with newlines
  (?m) to indicate that the expression to the right of the position turns on the specified multiline mode.
  Change the meaning of ^ and $ so that they match the beginning and end of any line, respectively,
  not just the beginning and end of the entire string.
  Note: (?m) Multiline mode is only used when the regular expression involves matching multiple lines of "^" and "$".
  The above matching patterns can be combined, such as (?is), (?im).
  In addition, you can use (?i:exp) or (?i)exp(?-i) to specify the valid range of matching.

 

 

This article is seen on the question and answer, and it is only used as a memo for easy query.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325102207&siteId=291194637