Basic method of python-re library

Continuously updating--------------

  • m = re.search(pattern,string) Search the entire string until a matching substring is found
  • m = re.match(pattern,string) Check whether the string conforms to the regular expression from the beginning, it must match from the first character of the string
  • str = re.sub(pattern,replacement,string)Use the regular transformation pattern to search in the string, and replace the searched string with another string replacement. Return the replaced string
  • re.split() Split string according to regular expression, put all substrings after splitting in a table and return
  • re.findall() Search for strings based on regular expressions, put all matching substrings in a table and return

Guess you like

Origin blog.csdn.net/weixin_43402353/article/details/109133886