Python provides simple string matching details and python string details.
Python for simple string matching
Since fields in specific formats need to be extracted from semi-structured text data, and data mining and analysis can be assisted, Matlab tools have been used for modeling structured data processing in the past, matlab is good at matrix processing and structured data computing. Python has the same features as matlab: Concise syntax and rich libraries. It is a simple and easy-to-use language for algorithm simulation.
Python is relatively easy to get started with string matching, and has a mature string processing library re for our use;
With the help of the re library, matching can be completed in just two simple steps. for data analysis/algorithm workers, it is much easier:
Step 1: Construct the regular expression mode and use the compile () function to generate a regular expression object.
Step 2: Call the method and attribute of the in-expression object generated by Step 1 and return the matching result.
<Span style = "color: #333300;"> # import the regular expression matching module Py 3.0 import re text = "today is 01/04/2015, happy new year... "# create a regular expression for date detepat = re. compile ('(\ d +)/(\ d +)') # match and print the result = detepat. finditer (text) for m in result: print (m. group () </span>
Thank you for reading this article. I hope it will help you. Thank you for your support for this site!