CN112069303B - Matching search method and device for character strings and terminal - Google Patents
Matching search method and device for character strings and terminal Download PDFInfo
- Publication number
- CN112069303B CN112069303B CN202010979282.XA CN202010979282A CN112069303B CN 112069303 B CN112069303 B CN 112069303B CN 202010979282 A CN202010979282 A CN 202010979282A CN 112069303 B CN112069303 B CN 112069303B
- Authority
- CN
- China
- Prior art keywords
- character
- string
- sub
- main
- characters
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/30—Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
- G06F16/33—Querying
- G06F16/332—Query formulation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/10—Text processing
- G06F40/12—Use of codes for handling textual entities
- G06F40/126—Character encoding
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- Computational Linguistics (AREA)
- General Physics & Mathematics (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Mathematical Physics (AREA)
- Health & Medical Sciences (AREA)
- Artificial Intelligence (AREA)
- Audiology, Speech & Language Pathology (AREA)
- General Health & Medical Sciences (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention relates to the technical field of data searching and identifying, aims to solve the problem of low efficiency of the existing matching and searching method of character strings, provides a matching and searching method, a device and a terminal of character strings, and adopts the following scheme: the method comprises the steps of aligning a character sub-string and a character main string on the left side, sequentially comparing each character of the character sub-string with each character of the character main string, judging whether the last character of the character sub-string is equal to the character of the character main string at the corresponding position when a certain character of the character sub-string fails to be matched with the character of the character main string at the corresponding position, if so, calculating the distance of the character sub-string moved to the right, wherein the character of the character sub-string moved to the right is the next character of the character main string at the corresponding position, and otherwise, calculating the distance of the character sub-string moved to the right is the last character of the character main string; and after the character substring moves rightwards for a certain distance, continuing to perform next matching. The invention improves the matching efficiency of the character strings. The method is suitable for an intrusion detection system.
Description
Technical Field
The invention relates to the technical field of data searching and identification, in particular to a matching searching method, a matching searching device and a terminal for character strings.
Background
With the rapid development and wide application of computer network technology in various fields, various resources are easily leaked, changed and damaged by viruses, hackers and the like, so that system abnormity, even breakdown and paralysis are caused, and huge economic loss is caused. The frequent network security problem is highly valued by people, and computer network security technology for protecting network information from various attacks is becoming more and more important. The intrusion detection system is one of the most widely used computer network security technologies, and is a network security device that monitors network transmissions in real time, and issues an alarm or takes active action when suspicious transmissions are found.
String matching is a common analysis method in intrusion detection systems, and the efficiency of string matching greatly determines the performance of intrusion detection systems. Through decades of research and practice at home and abroad, among a plurality of existing character string matching algorithms, the Horspool algorithm is a classical algorithm with fewer matching times and a simpler process. The Horspool algorithm is a suffix-based matching method, i.e., the comparison order is from the last character and the direction is from right to left. The specific operation process is that the last character of the main string of the text character is compared with the last character of the sub string of the text character, if the characters are equal, each character of the main string and the sub string is compared in turn from right to left until all the characters are completely equal or are not matched at a certain character. If not, the substring is moved to the right by a certain distance according to the next appearance position of the last character of the main string in the substring, and then the next matching is continued. The above process is repeated until all occurrences of a text character sub-string are found in the text character main string, and the algorithm terminates.
The core principle of the traditional Horspool algorithm can be abstractly summarized as follows: assuming that the length of the sub-string S is M, when matching fails, if the character corresponding to the last character of the sub-string S in the main string M is not in the first M-1 characters of the sub-string S, the distance of the sub-string S moving to the right is M, and the distance of the sub-string S moving to the right is smaller than M in the rest cases. Therefore, after each matching failure, the maximum distance that the Horspool algorithm can move rightwards is the length m of the substring S, so that the matching and searching method of the character strings based on the traditional Horspool algorithm has the problem of low efficiency.
Disclosure of Invention
The invention aims to solve the problem of low efficiency of the existing matching and searching method of a character string, and provides a matching and searching method, a device and a terminal of the character string.
The technical scheme adopted by the invention for solving the technical problems is as follows: the matching search method of the character string comprises the following steps:
step 1, aligning a first character of a character main string with a first character of a character sub-string, setting the length of the character sub-string as m, setting the length of the character main string as n, and setting m to be less than n;
step 2, comparing whether the characters on the corresponding positions of the character main string and the character sub string are matched or not in sequence, and finishing the matching process when all the characters of the character sub string are matched with the characters on the corresponding positions of the character main string;
step 3, when a certain character of the character sub-string is not matched with the character at the corresponding position of the character main string, judging whether the last character of the character sub-string is matched with the character at the corresponding position of the character main string, if so, entering step 4, otherwise, entering step 5;
step 5, calculating a moving distance according to characters at a second position of the character main string, wherein the second position is a corresponding position of the last character of the character sub-string;
and 6, moving the character substring to the right according to the moving distance calculated in the step 4 or the step 5, and entering the step 2.
Further, in step 3, the method for calculating the movement distance according to the character at the first position of the main character string includes:
and judging whether the first m-1 characters of the character sub-string contain the character at the first position of the character main string, if so, the moving distance is the sum of the distance between the character at the first position of the rightmost character main string and the last character of the character sub-string in the first m-1 characters of the character sub-string, otherwise, the moving distance is the sum of the length of the character sub-string and one.
Further, in step 4, the method for calculating the movement distance according to the character at the second position of the main character string includes:
and judging whether the first m-1 characters of the character sub-string contain the character at the second position of the character main string, if so, the moving distance is the distance between the character at the second position of the rightmost character main string and the last character of the character sub-string in the first m-1 characters of the character sub-string, and otherwise, the moving distance is the length of the character sub-string.
Further, in step 2, the method for sequentially comparing whether the characters at the corresponding positions of the character main string and the character sub-string are matched includes:
and sequentially comparing whether the characters on the corresponding positions of the character main string and the character sub-string are matched from right to left.
The invention also provides a matching and searching device for character strings, which comprises: the device comprises an alignment unit, a matching unit, a calculation unit and a moving unit;
the alignment unit is used for aligning the first character of the character main string with the first character of the character sub-string, the length of the character sub-string is set to be m, the length of the character main string is set to be n, and m is smaller than n;
the matching unit is used for sequentially comparing whether the characters on the corresponding positions of the character main string and the character sub-string are matched or not, and when all the characters of the character sub-string are matched with the characters on the corresponding positions of the character main string, the matching process is ended; when a certain character of the character sub-string is not matched with the character at the corresponding position of the character main string, judging whether the last character of the character sub-string is matched with the character at the corresponding position of the character main string;
the calculation unit is used for calculating a moving distance according to the character at the first position of the character master string when the last character of the character sub-string is matched with the character at the corresponding position of the character master string, wherein the first position is the next position of the corresponding position of the last character of the character sub-string; when the last character of the character sub-string is not matched with the character at the corresponding position of the character main string, calculating the moving distance according to the character at the second position of the character main string, wherein the second position is the corresponding position of the last character of the character sub-string;
the moving unit is used for moving the character substring to the right according to the moving distance calculated by the calculating unit.
Further, the computing unit is further configured to:
when the last character of the character sub-string is matched with the character at the corresponding position of the character main string, judging whether the first m-1 characters of the character sub-string contain the character at the first position of the character main string, if so, the moving distance is the distance between the character at the first position of the rightmost character main string and the last character of the character sub-string plus one in the first m-1 characters of the character sub-string, otherwise, the moving distance is the length of the character sub-string plus one.
Further, the computing unit is further configured to:
and when the last character of the character sub-string is not matched with the character at the corresponding position of the character main string, judging whether the first m-1 characters of the character sub-string contain the character at the second position of the character main string, if so, the moving distance is the distance between the character at the second position of the rightmost character main string and the last character of the character sub-string in the first m-1 characters of the character sub-string, otherwise, the moving distance is the length of the character sub-string.
Further, the matching unit is further configured to:
and sequentially comparing whether the characters on the corresponding positions of the character main string and the character sub-string are matched from right to left.
The invention also provides a terminal, which comprises a processor, a memory and a communication bus;
the communication bus is used for realizing connection communication between the processor and the memory;
the processor is configured to execute one or more programs in the memory to implement the steps of the string match lookup method.
The invention has the beneficial effects that: according to the matching and searching method, device and terminal of the character string, when the last character of the character sub-string is matched with the character at the corresponding position of the character main string, the moving distance is calculated according to the character at the first position of the character main string, the first position is the next position of the corresponding position of the last character of the character sub-string, and the maximum distance moving rightwards is the length of the character sub-string plus one. Compared with the traditional Horspool algorithm, the right-moving distance of the character substring is increased, the comparison times of each matching and the overall comparison times of the algorithm at the end are reduced, the time cost of successful matching is reduced, and the matching efficiency of the character string is improved.
Drawings
FIG. 1 is a schematic flow chart of a conventional Horspool algorithm;
fig. 2 is a schematic flow chart of a matching search method for a character string according to an embodiment of the present invention;
fig. 3 is another schematic flow chart of the method for matching and searching a character string according to the embodiment of the present invention;
fig. 4 is a schematic structural diagram of a matching search apparatus for character strings according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of a terminal according to an embodiment of the present invention.
Detailed Description
Embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
The invention aims to solve the problem of low efficiency of the existing matching and searching method of character strings, provides a matching and searching method, a device and a terminal of character strings, and the scheme is summarized as follows: step 1, aligning a first character of a character main string with a first character of a character sub-string, setting the length of the character sub-string as m, the length of the character main string as n, and setting m to be less than n; step 2, comparing whether the characters on the corresponding positions of the character main string and the character sub string are matched or not in sequence, and finishing the matching process when all the characters of the character sub string are matched with the characters on the corresponding positions of the character main string; step 3, when a certain character of the character sub-string is not matched with the character at the corresponding position of the character main string, judging whether the last character of the character sub-string is matched with the character at the corresponding position of the character main string, if so, entering step 4, otherwise, entering step 5; step 4, calculating a moving distance according to characters on a first position of the character main string, wherein the first position is a position next to a corresponding position of a last character of the character sub-string; step 5, calculating a moving distance according to characters at a second position of the character main string, wherein the second position is a corresponding position of the last character of the character sub string; and 6, moving the character substring to the right according to the moving distance calculated in the step 4 or the step 5, and entering the step 2.
Specifically, at the beginning of the algorithm, the character sub-string and the character main string are left aligned, and then each character of the character sub-string and the character main string is compared in turn. In the character comparison process, when a certain character of the character sub-string fails to be matched with the character at the corresponding position of the character main string, whether the last character of the character sub-string is equal to the character at the corresponding position of the character main string needs to be judged, and if the last character of the character sub-string is not equal to the character at the corresponding position of the character main string, the character used for calculating the distance of the character sub-string moving to the right is the last character in the character main string. And if the last character of the character sub-string is equal to the character at the corresponding position of the character main string, the character used for calculating the rightward movement distance of the character sub-string at the corresponding position is the next character of the character at the corresponding position of the character main string. And after the character substring moves rightwards for a certain distance, continuing to perform next matching.
Examples
To better understand the principle of the conventional Horspool algorithm, the process of the Horspool algorithm is described next as an example. It should be noted that the example is only for explaining the algorithm principle, so that the text character main string and the text character sub-string in this example have smaller length and simpler format. Let the text character main string be dbhallebelerle, length 19, and the text character sub string be S elerle, length 6. As shown in fig. 1, the conventional Horspool algorithm example string matching process has the following steps:
(1) match 1
Comparing the last character E of the character sub-string S with the last character L at the corresponding position of the character main string M, wherein E is not equal to L, namely the matching fails at the last character, the matching failed character is L, and because the character L is in the first 5 characters of the character sub-string S and the distance from the rightmost character L in the first 5 characters of the character sub-string S to the last character of the character sub-string S is 1, the distance that the character sub-string S should move rightwards before the next matching is 1.
(2) 2 nd match
And comparing the last character E of the character sub-string S with the last character E at the corresponding position of the character main string M, wherein E is equal to E, the last character is successfully matched, and then sequentially comparing the character sub-string S with each character of the character main string M from right to left from the previous character of the last character, and finding that the character E of the character sub-string S is not equal to the character A at the corresponding position of the character main string M, so that the matching is failed. In this match, the last character of the character sub-string S is aligned with the character master string M and since the character E is in the first 5 characters of the character sub-string S and the distance from the rightmost character E of the first 5 characters of the character sub-string S to the last character of the character sub-string S is 3, the sub-string S should be moved to the right by 3 before the next match.
(3) Match 3
And comparing the last character E of the character sub-string S with the last character E at the corresponding position of the character main string M, wherein E is equal to E, the last character is successfully matched, then sequentially comparing the characters of the character sub-string S and the character main string M from right to left from the previous character of the last character, and finding that the character L of the character sub-string S is not equal to the character H at the corresponding position of the character main string M, so that the matching is failed. In this match, the character in which the last character of the character sub-string S is aligned with the character main string M is E, and since the character E is in the first 5 characters of the character sub-string S and the distance from the rightmost character E of the first 5 characters of the character sub-string S to the last character of the character sub-string S is 3, the distance that the character sub-string S should be moved to the right before the next match is 3.
(4) Match 4
Comparing the last character E of the character sub-string S with the last character L at the corresponding position of the character main string M, wherein E is not equal to L, namely the matching fails at the last character, the matching failed character is L, and because the character L is in the first 5 characters of the character sub-string S and the distance from the rightmost character L in the first 5 characters of the character sub-string S to the last character of the character sub-string S is 1, the distance that the character sub-string S should move rightwards before the next matching is 1.
(5) Match 5
Comparing the last character E of the character sub-string S with the last character O at the corresponding position of the character main string M, wherein E is not equal to O, namely the matching fails at the last character, the matching failed character is O, and because the character O is in the first 5 characters of the character sub-string S and the distance from the rightmost character O in the first 5 characters of the character sub-string S to the last character of the character sub-string S is 5, the distance that the character sub-string S should move rightwards before the next matching is 5.
(6) Match 6
And comparing the last character E of the character sub-string S with the last character E at the corresponding position of the character main string M, wherein E is equal to E, the last character is successfully matched, and then sequentially comparing the characters of the character sub-string S and the character main string M from the right to the left from the previous character of the last character, and finding that each character of the character sub-string S is equal to the character at the corresponding position of the character main string M, so that the matching is successful.
It can be seen that, in this embodiment, with the conventional Horspool algorithm, the maximum distance that a character sub-string can move rightward is the length m of the character sub-string S, and it takes 6 times to achieve successful matching, which is inefficient.
Based on this, the embodiment of the present invention provides an improved matching and searching method for a character string, as shown in fig. 2, including the following steps:
step 1, aligning a first character of a character main string with a first character of a character sub-string, setting the length of the character sub-string as m, the length of the character main string as n, and setting m to be less than n;
step 2, comparing whether the characters on the corresponding positions of the character main string and the character sub string are matched or not in sequence, and finishing the matching process when all the characters of the character sub string are matched with the characters on the corresponding positions of the character main string;
step 3, when a certain character of the character sub-string is not matched with the character at the corresponding position of the character main string, judging whether the last character of the character sub-string is matched with the character at the corresponding position of the character main string, if so, entering step 4, otherwise, entering step 5;
the method for calculating the moving distance according to the characters on the first position of the character main string comprises the following steps:
and judging whether the first m-1 characters of the character sub-string contain the character at the first position of the character main string, if so, the moving distance is the sum of the distance between the character at the first position of the rightmost character main string and the last character of the character sub-string in the first m-1 characters of the character sub-string, and otherwise, the moving distance is the sum of the length of the character sub-string and one.
Step 5, calculating a moving distance according to characters at a second position of the character main string, wherein the second position is a corresponding position of the last character of the character sub-string;
the method for calculating the moving distance according to the character at the second position of the character main string comprises the following steps:
and judging whether the first m-1 characters of the character sub-string contain the character at the second position of the character main string, if so, the moving distance is the distance between the character at the second position of the rightmost character main string and the last character of the character sub-string in the first m-1 characters of the character sub-string, and otherwise, the moving distance is the length of the character sub-string.
And 6, moving the character substring to the right according to the moving distance calculated in the step 4 or the step 5, and entering the step 2.
According to the steps, the maximum distance of moving rightwards in the matching process is m +1, compared with the traditional Horspool algorithm, the moving distance of the character substring rightwards is increased, the integral matching times are reduced, the time cost is reduced, and the efficiency of the algorithm can be effectively improved in the character string matching of mass data.
In order to better understand the principle of the embodiment of the present invention, the following describes the flow of the matching search method for character strings in the embodiment of the present invention with the same character main string and character sub-string as those in the conventional Horspool algorithm embodiment. Let the text character main string be dbhallebelerle, length 19, and the text character sub string be S elerle, length 6. As shown in fig. 3, the method for searching for a matching of a character string according to the embodiment of the present invention includes the following steps:
(1) match 1
Comparing the last character E of the character sub-string S with the last character L at the corresponding position of the character main string M, wherein E is not equal to L, namely the matching fails at the last character, because the last character L at the corresponding position of the character main string M is in the first 5 characters of the character sub-string S and the distance from the rightmost L in the first 5 characters of the character sub-string S to the last character of the character sub-string S is 1, the distance that the character sub-string S should move to the right before the next matching is 1.
(2) 2 nd match
And comparing the last character E of the character sub-string S with the last character E at the corresponding position of the character main string M, wherein E is equal to E, the last character is successfully matched, and then sequentially comparing the character sub-string S with each character of the character main string M from right to left from the previous character of the last character, and finding that the character E of the character sub-string S is not equal to the character A at the corresponding position of the character main string M, so that the matching is failed. In this matching, the last character of the character sub-string S is matched with the last character of the character main string M, both are E, the character used for calculating the movement distance is the next character B of the last character E in the character main string M, and since the character B is not in the first 5 characters of the character sub-string S, the distance that the character sub-string S should move right before the next matching is the length 6 of itself plus 1, that is, 7.
(3) Match 3
Comparing the last character E of the character sub-string S with the last character O at the corresponding position of the character main string M, wherein E is not equal to O, namely the matching fails at the last character, because the last character O at the corresponding position of the character main string M is in the first 5 characters of the sub-string S and the distance from the rightmost character O in the first 5 characters of the character sub-string S to the last character of the character sub-string S is 5, the distance that the character sub-string S should move rightwards before the next matching is 5.
(4) Match 4
And comparing the last character E of the character sub-string S with the last character E at the corresponding position of the character main string M, wherein E is equal to E, the last character is successfully matched, and then sequentially comparing the characters of the character sub-string S and the character main string M from the right to the left from the previous character of the last character, and finding that each character of the character sub-string S is equal to the character at the corresponding position of the character main string M, so that the matching is successful.
It can be seen that 4 comparisons are needed for successful matching by using the matching and searching method for character strings in the embodiment of the present invention, which is 2 times less than that of the conventional Horspool algorithm. In practical application, for character main strings and character sub-strings with longer length and more complex data formats, the improved algorithm has more obvious advantages, reduces more comparison times, and can effectively reduce time cost and improve algorithm efficiency.
Based on the above technical solution, an embodiment of the present invention further provides a device for matching and searching a character string, as shown in fig. 4, including: the device comprises an alignment unit, a matching unit, a calculation unit and a moving unit;
the alignment unit is used for aligning the first character of the character main string with the first character of the character sub-string, the length of the character sub-string is set to be m, the length of the character main string is set to be n, and m is smaller than n;
the matching unit is used for sequentially comparing whether the characters on the corresponding positions of the character main string and the character sub-string are matched or not, and when all the characters of the character sub-string are matched with the characters on the corresponding positions of the character main string, the matching process is ended; when a certain character of the character sub-string is not matched with the character at the corresponding position of the character main string, judging whether the last character of the character sub-string is matched with the character at the corresponding position of the character main string;
the calculation unit is used for calculating the moving distance according to the character at the first position of the character master string when the last character of the character sub string is matched with the character at the corresponding position of the character master string, and the first position is the next position of the corresponding position of the last character of the character sub string; when the last character of the character sub-string is not matched with the character at the corresponding position of the character main string, calculating the moving distance according to the character at the second position of the character main string, wherein the second position is the corresponding position of the last character of the character sub-string;
the moving unit is used for moving the character substring to the right according to the moving distance calculated by the calculating unit.
An embodiment of the present invention further provides a terminal, as shown in fig. 5, where the terminal includes a processor, a memory, and a communication bus;
the communication bus is used for realizing connection communication between the processor and the memory;
the processor is configured to execute one or more programs in the memory to implement the steps of the matching search method for character strings.
It can be understood that, the device and the terminal for matching and searching a character string according to the embodiments of the present invention are a device and a terminal for implementing the method for matching and searching a character string according to the embodiments, and for the device and the terminal disclosed in the embodiments, since they correspond to the method disclosed in the embodiments, the description is simpler, and for the relevant points, reference may be made to the partial description of the method.
Claims (9)
1. The matching search method of the character string is characterized by comprising the following steps:
step 1, aligning a first character of a character main string with a first character of a character sub-string, setting the length of the character sub-string as m, setting the length of the character main string as n, and setting m to be less than n;
step 2, comparing whether the characters on the corresponding positions of the character main string and the character sub string are matched or not in sequence, and finishing the matching process when all the characters of the character sub string are matched with the characters on the corresponding positions of the character main string;
step 3, when a certain character of the character sub-string is not matched with the character at the corresponding position of the character main string, judging whether the last character of the character sub-string is matched with the character at the corresponding position of the character main string, if so, entering step 4, otherwise, entering step 5;
step 4, calculating a moving distance according to characters on a first position of the character main string, wherein the first position is a position next to a corresponding position of a last character of the character sub-string;
step 5, calculating a moving distance according to characters at a second position of the character main string, wherein the second position is a corresponding position of the last character of the character sub-string;
and 6, moving the character substring to the right according to the moving distance calculated in the step 4 or the step 5, and entering the step 2.
2. The method for searching for string matching according to claim 1, wherein in step 3, the method for calculating the moving distance according to the character at the first position of the main string comprises:
and judging whether the first m-1 characters of the character sub-string contain the character at the first position of the character main string, if so, the moving distance is the sum of the distance between the character at the first position of the rightmost character main string and the last character of the character sub-string in the first m-1 characters of the character sub-string, and otherwise, the moving distance is the sum of the length of the character sub-string and one.
3. The method for searching for character string matching according to claim 1 or 2, wherein in step 4, the method for calculating the moving distance according to the character at the second position of the main character string comprises:
and judging whether the first m-1 characters of the character sub-string contain the character at the second position of the character main string, if so, the moving distance is the distance between the character at the second position of the rightmost character main string and the last character of the character sub-string in the first m-1 characters of the character sub-string, and otherwise, the moving distance is the length of the character sub-string.
4. The method for searching for character string matching according to claim 1, wherein in step 2, the method for sequentially comparing whether the characters at the corresponding positions of the character main string and the character sub-string are matched comprises:
and sequentially comparing whether the characters on the corresponding positions of the character main string and the character sub-string are matched from right to left.
5. Matching of character string seeks device, its characterized in that includes: the device comprises an alignment unit, a matching unit, a calculation unit and a moving unit;
the alignment unit is used for aligning the first character of the character main string with the first character of the character sub-string, the length of the character sub-string is set to be m, the length of the character main string is set to be n, and m is smaller than n;
the matching unit is used for sequentially comparing whether the characters on the corresponding positions of the character main string and the character sub-string are matched or not, and when all the characters of the character sub-string are matched with the characters on the corresponding positions of the character main string, the matching process is ended; when a certain character of the character sub-string is not matched with the character at the corresponding position of the character main string, judging whether the last character of the character sub-string is matched with the character at the corresponding position of the character main string;
the calculation unit is used for calculating a moving distance according to the character at the first position of the character master string when the last character of the character sub-string is matched with the character at the corresponding position of the character master string, wherein the first position is the next position of the corresponding position of the last character of the character sub-string; when the last character of the character sub-string is not matched with the character at the corresponding position of the character main string, calculating the moving distance according to the character at the second position of the character main string, wherein the second position is the corresponding position of the last character of the character sub-string;
the moving unit is used for moving the character substring to the right according to the moving distance calculated by the calculating unit.
6. The apparatus for string match finding as claimed in claim 5, wherein said computing unit is further configured to:
when the last character of the character sub-string is matched with the character at the corresponding position of the character main string, judging whether the first m-1 characters of the character sub-string contain the character at the first position of the character main string, if so, the moving distance is the distance between the character at the first position of the rightmost character main string and the last character of the character sub-string plus one in the first m-1 characters of the character sub-string, otherwise, the moving distance is the length of the character sub-string plus one.
7. A string match-finding apparatus as claimed in claim 5 or 6, wherein said computing unit is further adapted to:
and when the last character of the character sub-string is not matched with the character at the corresponding position of the character main string, judging whether the first m-1 characters of the character sub-string contain the character at the second position of the character main string, if so, the moving distance is the distance between the character at the second position of the rightmost character main string and the last character of the character sub-string in the first m-1 characters of the character sub-string, otherwise, the moving distance is the length of the character sub-string.
8. The apparatus for matching and searching character strings according to claim 5, wherein said matching unit is further configured to:
and sequentially comparing whether the characters on the corresponding positions of the character main string and the character sub-string are matched from right to left.
9. A terminal, characterized in that the terminal comprises a processor, a memory and a communication bus;
the communication bus is used for realizing connection communication between the processor and the memory;
the processor is configured to execute one or more programs in the memory to implement the steps of the method of matching a string of characters for finding as claimed in any one of claims 1 to 4.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010979282.XA CN112069303B (en) | 2020-09-17 | 2020-09-17 | Matching search method and device for character strings and terminal |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010979282.XA CN112069303B (en) | 2020-09-17 | 2020-09-17 | Matching search method and device for character strings and terminal |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112069303A CN112069303A (en) | 2020-12-11 |
CN112069303B true CN112069303B (en) | 2022-08-16 |
Family
ID=73681639
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010979282.XA Active CN112069303B (en) | 2020-09-17 | 2020-09-17 | Matching search method and device for character strings and terminal |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112069303B (en) |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113609352B (en) * | 2021-08-03 | 2023-08-04 | 北京恒安嘉新安全技术有限公司 | Character string retrieval method, device, computer equipment and storage medium |
CN113836367B (en) * | 2021-09-26 | 2023-04-28 | 杭州迪普科技股份有限公司 | Method and device for character reverse matching |
CN114461865A (en) * | 2022-03-14 | 2022-05-10 | 深圳希施玛数据科技有限公司 | Character string matching method, device and storage medium |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CA2091503A1 (en) * | 1992-03-18 | 1993-09-19 | Brenda Sue Baker | Apparatus for studying large sets of data |
CN101377816A (en) * | 2008-08-15 | 2009-03-04 | 北京启明星辰信息技术股份有限公司 | Method and system for matching paralleling multiple-mode of matching regulation including displacement indication symbol |
CN102063510A (en) * | 2011-01-17 | 2011-05-18 | 珠海全志科技有限公司 | Method for searching matched character string |
WO2015100574A1 (en) * | 2013-12-31 | 2015-07-09 | 华为终端有限公司 | Method and device for string input control |
CN109977276A (en) * | 2019-03-22 | 2019-07-05 | 华南理工大学 | A kind of single pattern matching method based on Sunday algorithm improvement |
CN111125459A (en) * | 2019-12-25 | 2020-05-08 | 中消云(北京)物联网科技研究院有限公司 | Character string processing method and device |
WO2020165136A1 (en) * | 2019-02-15 | 2020-08-20 | International Business Machines Corporation | Vector string search instruction |
Family Cites Families (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101763260B (en) * | 2009-12-31 | 2011-07-27 | 北京神州泰岳软件股份有限公司 | Dynamic authorizing method of data based on ITSM system |
CN101901268B (en) * | 2010-08-02 | 2011-12-21 | 华为技术有限公司 | Rule matching method and device |
CN103425739B (en) * | 2013-07-09 | 2016-09-14 | 国云科技股份有限公司 | A kind of character string matching method |
CN103533448B (en) * | 2013-10-31 | 2017-12-08 | 乐视致新电子科技(天津)有限公司 | The cursor control method and cursor control device of intelligent television |
CN103577598B (en) * | 2013-11-15 | 2017-02-15 | 曙光信息产业(北京)有限公司 | Matching method and device for pattern string and text string |
CN104519056B (en) * | 2014-12-15 | 2017-09-08 | 广东科学技术职业学院 | A kind of single pattern matching method jumped based on double jump |
CN104615782B (en) * | 2015-03-02 | 2017-10-10 | 武汉工程大学 | Address matching process based on sliding window maximum matching algorithm |
CN104836841B (en) * | 2015-03-31 | 2018-03-30 | 重庆邮电大学 | A kind of management method of sensor network sensing node identification (RNC-ID) analytic procedural information |
CN107197457A (en) * | 2017-04-11 | 2017-09-22 | 厦门市美亚柏科信息股份有限公司 | The electronic data evidence obtaining method and its system of pseudo-base station |
CN107239500A (en) * | 2017-05-03 | 2017-10-10 | 成都国腾实业集团有限公司 | A kind of character string matching method and system |
CN107341224A (en) * | 2017-06-30 | 2017-11-10 | 北方工业大学 | The matching process and device of a kind of character string |
CN107229759B (en) * | 2017-07-27 | 2020-08-11 | 深圳市乐宜科技有限公司 | Method for matching character string mode |
-
2020
- 2020-09-17 CN CN202010979282.XA patent/CN112069303B/en active Active
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CA2091503A1 (en) * | 1992-03-18 | 1993-09-19 | Brenda Sue Baker | Apparatus for studying large sets of data |
CN101377816A (en) * | 2008-08-15 | 2009-03-04 | 北京启明星辰信息技术股份有限公司 | Method and system for matching paralleling multiple-mode of matching regulation including displacement indication symbol |
CN102063510A (en) * | 2011-01-17 | 2011-05-18 | 珠海全志科技有限公司 | Method for searching matched character string |
WO2015100574A1 (en) * | 2013-12-31 | 2015-07-09 | 华为终端有限公司 | Method and device for string input control |
WO2020165136A1 (en) * | 2019-02-15 | 2020-08-20 | International Business Machines Corporation | Vector string search instruction |
CN109977276A (en) * | 2019-03-22 | 2019-07-05 | 华南理工大学 | A kind of single pattern matching method based on Sunday algorithm improvement |
CN111125459A (en) * | 2019-12-25 | 2020-05-08 | 中消云(北京)物联网科技研究院有限公司 | Character string processing method and device |
Also Published As
Publication number | Publication date |
---|---|
CN112069303A (en) | 2020-12-11 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN112069303B (en) | Matching search method and device for character strings and terminal | |
US9256831B2 (en) | Match engine for detection of multi-pattern rules | |
US9514246B2 (en) | Anchored patterns | |
CN107122221B (en) | Compiler for regular expressions | |
CN102184197B (en) | Regular expression matching method based on smart finite automaton (SFA) | |
US9350707B2 (en) | System and method for detecting a compromised computing system | |
Huang et al. | Adversarial attack against LSTM-based DDoS intrusion detection system | |
CN112039196A (en) | Power monitoring system private protocol analysis method based on protocol reverse engineering | |
CN113422763B (en) | Alarm correlation analysis method constructed based on attack scene | |
CN113556343B (en) | DDoS attack defense method and device based on browser fingerprint identification | |
CN104850784A (en) | Method and system for cloud detection of malicious software based on Hash characteristic vector | |
CN112532642A (en) | Industrial control system network intrusion detection method based on improved Suricata engine | |
CN113141331A (en) | XSS attack detection method, device, equipment and medium | |
CN103324886A (en) | Method and system for extracting fingerprint database in network intrusion detection | |
CN112507336A (en) | Server-side malicious program detection method based on code characteristics and flow behaviors | |
WO2013154252A1 (en) | Method, server, terminal device, and computer-readable recording medium for selectively removing nondeterminism of nondeterministic finite automata | |
RU2615317C1 (en) | Method for detection of malicious software codes in network data traffic, including exposed to combination of polymorphic transformations | |
US9104866B2 (en) | Pattern matching engine, terminal apparatus using the same, and method thereof | |
CN114169540A (en) | Webpage user behavior detection method and system based on improved machine learning | |
CN114422389B (en) | High-speed real-time network data monitoring method based on hash and hardware acceleration | |
CN114745200B (en) | Malicious code detection method based on malicious code dynamic evidence obtaining model | |
Wang et al. | BiBE: A Self-supervised Contrastive Learning Architecture for Malware Detection | |
EP3151149B1 (en) | System and method for blocking execution of scripts | |
Zhu et al. | Research of BM Algorithm in Character Match | |
CN118898071A (en) | APT attack tracing method integrating sequence learning and causal analysis |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |