Based on tcp packet matching regular expression

The present invention provides a TCP packet matching method based on a regular expression, comprising: reading all regular expression rules, arranged to match a rule list; of TCP packets sequentially field by field according to the field order regex matching: according to the current contents of the field to traverse its corresponding list of matching rules, would conflict with the current field contents matching rules to remove the matching rules list; if the regular expression there is no corresponding field in matching rules, then the TCP packet fails to match ; If the regular expression in each field has a corresponding matching rules, then the TCP packet matching is successful, allow packets to pass. TCP packet matching method of the present invention has high efficiency, good security.