Key step sequence matching method and device
By comparing the expected and the text content sequence to be verified with preset matching rules, the problem of existing tools being unable to verify the order of key steps is solved, realizing efficient and flexible verification of the order of key steps, and meeting the needs of software testing and log analysis.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- NEUSOFT REACH AUTOMOBILE TECH (SHENYANG) CO LTD
- Filing Date
- 2026-03-18
- Publication Date
- 2026-05-19
AI Technical Summary
Existing text comparison tools cannot effectively verify whether key steps appear in the expected order. Especially in process testing or state machine verification, the presence of non-critical information leads to verification failure, making it difficult to flexibly and efficiently verify the order of key steps in the process.
A method for matching the sequence of key steps is provided. By using preset matching rules, the expected text content sequence is compared with the text content sequence to be verified one by one. Inconsistencies in some content are allowed. Only the sequence matching of key steps is verified and the matching result is output.
It enables precise verification of the order of key steps in a text content sequence, improves verification efficiency, provides clear verification result feedback, and supports automated verification in fields such as software testing and log analysis.
Smart Images

Figure CN122065052A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of text processing technology, and in particular to a method and apparatus for matching the sequence of key steps. Background Technology
[0002] In software testing, automated script verification, and log analysis, it's often necessary to compare the content of two text sequences to see if they are identical or appear in the expected order. Currently used text comparison tools, such as diff tools, require the content of the two files to be completely identical for a successful match. However, in practical applications, especially in scenarios like process testing or state machine verification, the text sequence to be verified may contain a large amount of non-critical information or intermediate process information, while users only care whether a few key steps appear in the expected order. In this case, using a diff tool will cause the entire verification to fail due to inconsistencies in non-critical content, making it impossible to verify only the order of key steps.
[0003] Another commonly used tool is the grep-like utility, which can match the presence of a keyword in text. However, grep-like tools typically only perform single or multiple independent matches and cannot determine whether multiple key steps appear in a text sequence in a specified order. Therefore, existing technology lacks an effective tool specifically designed to verify whether key steps appear in the expected order, even when some inconsistencies are allowed. This technological deficiency makes it difficult to efficiently and flexibly verify the order of key steps in automated testing, such as OTA upgrade testing or protocol process verification. Summary of the Invention
[0004] To address the aforementioned issues, this application provides a method and apparatus for matching the sequence of key steps.
[0005] The embodiments of this application disclose the following technical solutions: In a first aspect, embodiments of this application provide a method for matching the sequence of key steps, the method comprising: Obtain the expected text content sequence and the text content sequence to be verified; Based on preset matching rules, each expected text content in the expected text content sequence is matched with the text content sequence to be verified in sequence to determine whether there is a successful matching sequence in the text content sequence to be verified that is consistent with the order of the expected text content sequence. Output the matching results.
[0006] In one possible implementation, the matching rules include a first matching pattern and a second matching pattern; The step of matching each expected text content in the expected text content sequence with the text content sequence to be verified in sequence according to a preset matching rule includes: When the matching rule is the first matching mode, and the current text content to be verified in the text content sequence to be verified includes the current expected text content in the expected text content sequence, it is determined that the match is successful; When the matching rule is the second matching mode, and the current text content to be verified in the text content sequence to be verified is the same as the current expected text content in the expected text content sequence, the match is determined to be successful.
[0007] In one possible implementation, the step of matching each expected text content in the expected text content sequence with the text content sequence to be verified in sequence according to a preset matching rule includes: Initialize a first pointer pointing to the current expected text content to be matched in the expected text content sequence, and initialize a second pointer pointing to the current text content to be matched in the text content sequence to be verified; According to the matching rules, determine whether the text content to be verified currently pointed to by the second pointer matches the expected text content currently pointed to by the first pointer; If a match is found, both the first pointer and the second pointer are moved simultaneously. If a match fails, move the second pointer; Repeat the matching judgment and pointer movement steps until all expected text content in the expected text content sequence is successfully matched, or the text content sequence to be verified has been traversed.
[0008] In one possible implementation, the matching rule is specified via command-line arguments; The process of obtaining the expected text content sequence and the text content sequence to be verified includes: The command-line parameters are parsed to obtain a first file path parameter, a second file path parameter, and a pattern parameter indicating the matching pattern; wherein, the first file path parameter is used to indicate the source of the expected text content sequence; the second file path parameter is used to indicate the source of the text content sequence to be verified; and the pattern parameter is used to indicate the matching pattern. The file is read according to the first file path parameter, and the expected text content sequence is generated. The file is read according to the second file path parameter, and the sequence of text content to be verified is generated.
[0009] In one possible implementation, the command-line parameters also include a regular expression parameter indicating whether regular expression matching is enabled; when regular expression matching is enabled, a successful match includes: The current text content to be verified in the sequence of text content to be verified matches the regular expression represented by the current expected text content in the sequence of expected text content.
[0010] In one possible implementation, the output matching result includes: If all expected text contents in the expected text content sequence are matched successfully in sequence, then the first status code indicating a successful match is output. If there is unmatched expected text content, output a second status code indicating a failed match, along with information about the unmatched expected text content.
[0011] In one possible implementation, outputting information about the expected text content that failed to match includes: Output the position information and / or content of the unmatched expected text content in the expected text content sequence.
[0012] Secondly, embodiments of this application disclose a key step sequence matching device, the device comprising: The acquisition module is used to acquire the expected text content sequence and the text content sequence to be verified; The matching module is used to match each expected text content in the expected text content sequence with the text content sequence to be verified in sequence according to a preset matching rule, and to determine whether there is a successful matching sequence in the text content sequence to be verified that is consistent with the order of the expected text content sequence. The output module is used to output the matching results.
[0013] In one possible implementation, the matching rules include a first matching pattern and a second matching pattern; The matching module is specifically used to determine a successful match when the matching rule is the first matching mode and the current text content to be verified in the text content sequence to be verified includes the current expected text content in the expected text content sequence; and when the matching rule is the second matching mode and the current text content to be verified in the text content sequence to be verified is the same as the current expected text content in the expected text content sequence.
[0014] In one possible implementation, the matching module is specifically used to initialize a first pointer pointing to the current expected text content to be matched in the expected text content sequence, and initialize a second pointer pointing to the current expected text content to be matched in the text content sequence to be verified; according to the matching rules, determine whether the text content to be verified currently pointed to by the second pointer matches the expected text content currently pointed to by the first pointer; if the match is successful, move both the first pointer and the second pointer simultaneously; if the match fails, move the second pointer; repeat the matching judgment and pointer movement steps until all expected text content in the expected text content sequence is successfully matched, or the text content sequence to be verified has been traversed.
[0015] In one possible implementation, the matching rule is specified via command-line arguments; The acquisition module is specifically used to parse the command-line parameters to obtain a first file path parameter, a second file path parameter, and a mode parameter for indicating the matching mode; wherein, the first file path parameter is used to indicate the source of the expected text content sequence; the second file path parameter is used to indicate the source of the text content sequence to be verified; the mode parameter is used to indicate the matching mode; the file is read according to the first file path parameter to generate the expected text content sequence; the file is read according to the second file path parameter to generate the text content sequence to be verified.
[0016] In one possible implementation, the command-line parameters further include a regular expression parameter for indicating whether regular expression matching is enabled; when regular expression matching is enabled, a successful match includes: the current text content to be verified in the sequence of text content to be verified matches the regular expression represented by the current expected text content in the sequence of expected text content.
[0017] In one possible implementation, the output module is specifically used to output a first status code indicating a successful match if all expected text content in the expected text content sequence is matched successfully in sequence; and to output a second status code indicating a failed match and information about the unmatched expected text content if there is unmatched expected text content.
[0018] In one possible implementation, the output module is specifically used to output the position information and / or content of the unmatched expected text content in the expected text content sequence.
[0019] Thirdly, embodiments of this application disclose a control device, including a processor and a memory, wherein the memory is used to store programs, instructions or code, and the processor is used to execute the programs, instructions or code in the memory to complete the key step sequence matching method as described in any of the first aspects.
[0020] Fourthly, embodiments of this application disclose a computer-readable storage medium, characterized in that it stores a computer program, which is loaded by a processor to execute the key step sequence matching method as described in any of the first aspects.
[0021] This application provides a key step sequence matching method. The method first obtains the expected text content sequence and the text content sequence to be verified. Then, according to the preset matching rules, each expected text content in the expected text content sequence is matched with the text content sequence to be verified in a predetermined order. The method then determines whether there is a successful matching sequence in the text content sequence to be verified that is consistent with the order of the expected text content sequence. Finally, the overall matching result is output.
[0022] This method abandons the traditional text comparison approach that only verifies complete content consistency or the presence of a single keyword. Instead, it enables targeted verification of the sequence of key steps within a text content sequence. It can accurately determine whether a content sequence matching the expected order exists within the text content sequence to be verified, meeting the core needs of software testing, log analysis, and other fields for step sequence matching verification. Furthermore, by directly outputting the matching results, it provides intuitive feedback on the verification status, eliminating the need for manual line-by-line text comparison. This effectively improves the efficiency of key step sequence matching verification and provides a clear basis for subsequent operations such as problem localization and process verification based on the matching results. Attached Figure Description
[0023] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0024] Figure 1 A flowchart illustrating a key step sequence matching method provided in an embodiment of this application; Figure 2 This is a schematic diagram of a key step sequence matching device provided in an embodiment of this application. Detailed Implementation
[0025] As described earlier, in software testing, log analysis, and automated process verification scenarios, it is often necessary to verify whether the expected critical steps appear in the order of a text sequence (such as log files or output results). Existing technologies either require complete consistency (such as diff tools), leading to verification failures due to differences in non-critical content, or can only perform independent keyword searches (such as grep tools), failing to verify the order of multiple keywords.
[0026] To address this technical problem, this application provides a key step sequence matching method. The method first obtains the expected text content sequence and the text content sequence to be verified. Then, according to the preset matching rules, each expected text content in the expected text content sequence is matched with the text content sequence to be verified in a predetermined order. The method then determines whether there is a successful matching sequence in the text content sequence to be verified that is consistent with the order of the expected text content sequence. Finally, the overall matching result is output.
[0027] This method abandons the traditional text comparison approach that only verifies complete content consistency or the presence of a single keyword. Instead, it enables targeted verification of the sequence of key steps within a text content sequence. It can accurately determine whether a content sequence matching the expected order exists within the text content sequence to be verified, meeting the core needs of software testing, log analysis, and other fields for step sequence matching verification. Furthermore, by directly outputting the matching results, it provides intuitive feedback on the verification status, eliminating the need for manual line-by-line text comparison. This effectively improves the efficiency of key step sequence matching verification and provides a clear basis for subsequent operations such as problem localization and process verification based on the matching results.
[0028] The method provided in this application aims to solve this problem by sequentially matching key steps, allowing for additional, unexpected content in the text sequence to be verified, thereby enabling flexible and efficient verification of the correctness of the process.
[0029] The method provided in this application can be used with various hardware devices equipped with command-line environments, such as personal computers, workstations, production line industrial control computers, automotive diagnostic tools, and CI / CD automated test servers. It is widely applied in key step sequence verification scenarios across multiple fields, including software development, automated testing, automotive electronics, and industrial control. In automotive electronics testing scenarios, production line industrial control computers or portable diagnostic tools can be equipped with this command-line tool to perform fuzzy or consistent pattern sequence matching between the expected step files corresponding to OTA upgrades and ECU flashing enterprise standards and the log files generated by the actual execution of the equipment, verifying whether the key steps of the flashing and upgrade process are executed according to regulations.
[0030] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of the present application.
[0031] See Figure 1 , Figure 1 This is a flowchart illustrating a key step sequence matching method provided in an embodiment of this application. The executing entity of this method can be a server, desktop computer, or other electronic device capable of computation. The following description uses an electronic device as the executing entity, and the method includes: S101: The electronic device acquires the expected text content sequence and the text content sequence to be verified.
[0032] The expected text content sequence is a collection of key step text content arranged according to a preset business process and verification requirements. The order of each text content in the sequence is the target order to be verified. It is usually written in advance by the user and stored in the form of files, memory arrays, etc.
[0033] The text content sequence to be verified is a collection of text content generated during actual business execution, program operation, or device operation, recorded in the actual order of occurrence. It is the object that needs to be verified to see if it conforms to the expected order, and can come from log files, script execution records, device operation output, etc.
[0034] Electronic devices can acquire the expected text content sequence and the text content sequence to be verified in various ways. The most common method is to read a preset file from local storage media and parse the file content line by line into an ordered sequence. For example, a user-pre-written expected file containing key steps (such as a.txt) can be loaded line by line, with each line as an element of the sequence to form the expected text content sequence. The logs and execution records generated during the actual operation, which are to be verified (such as b.txt), can be parsed in the same line-by-line manner to form the text content sequence to be verified, ensuring that both sequences strictly retain the line order of the original text.
[0035] In addition to local file reading, electronic devices can also adapt to other acquisition methods. For example, they can receive text content data streams to be verified from peripherals such as industrial control computers on production lines and automotive diagnostic tools via industrial networks, and construct a sequence of text content to be verified according to the receiving order; or they can directly retrieve the expected / to-be-verified text content array generated in real time by other programs or scripts from their own memory, without the need for additional file storage, and directly use the memory array as the corresponding text content sequence to meet the fast acquisition needs in different scenarios. Regardless of the acquisition method used, the electronic device will guarantee the order of the two acquired sequences, that is, the order of the elements in the sequence is completely consistent with the order of the original text content.
[0036] In one possible implementation, embodiments of this application can synchronously obtain the expected text content sequence and the text content sequence to be verified by parsing command line parameters, making the entire method call more lightweight and standardized, and can be directly integrated into the command line or automated script.
[0037] Specifically, obtaining the expected text content sequence and the text content sequence to be verified includes: The electronic device parses command-line arguments to obtain a first file path parameter, a second file path parameter, and a pattern parameter indicating the matching pattern. The electronic device reads the file based on the first file path parameter to generate the expected text content sequence; and reads the file based on the second file path parameter to generate the text content sequence to be verified.
[0038] The electronic device receives complete parameter commands input by the user in the command line, parses and processes these commands, and extracts a first file path parameter, a second file path parameter, and a mode parameter. The first file path parameter points to the source file of the expected text content sequence, the second file path parameter points to the source file of the text content sequence to be verified, and the mode parameter specifies the particular matching mode to be used for subsequent matching. This mode parameter includes two optional types: fuzzy matching and consistent matching, corresponding to the `--mode` command in the command line parameters.
[0039] After the electronic device completes parameter parsing, it first accurately locates the specific storage location of the expected file in the local storage medium according to the indication of the first file path parameter. Then, it loads the entire content of the file in a line-by-line reading manner, treating each line of text content in the file as an independent element. It then combines all elements into an ordered sequence of expected text content in strict accordance with the line reading order. The order of the elements in the sequence is completely consistent with the line order in the expected file, ensuring that the expected key steps are not disordered.
[0040] After generating the expected text content sequence, the electronic device processes the second file path parameter according to exactly the same file reading and sequence generation rules. Locate the storage location of the file to be verified based on the second file path parameter, read the file content line by line, and generate the text content sequence to be verified with each line as an element in the line order, ensuring that the generation logic of the two text content sequences is unified, and providing a standardized and ordered data source for subsequent sequential matching operations. At the same time, the electronic device will temporarily store the parsed pattern parameters, and the pattern parameters will be used as the direct execution basis for the preset matching rules in the subsequent matching steps, realizing the linkage completion of the matching rule configuration and the acquisition of the text content sequence without additional manual configuration steps.
[0041] S102: The electronic device sequentially matches each expected text content in the expected text content sequence with the text content sequence to be verified based on the preset matching rules, and determines whether there is a successful matching sequence in the text content sequence to be verified that is consistent with the order of the expected text content sequence.
[0042] The matching rule is a pre-configured determination criterion for determining whether a single expected text content matches the text content to be verified, and at least includes a first matching mode and a second matching mode. As an example, the first matching mode is a consistent matching rule, and the second matching mode is a fuzzy matching rule. The matching rule can be specified by command line parameters or set in a local configuration file.
[0043] In the embodiment of the present application, taking the first matching mode as the consistent matching rule and the second matching mode as the fuzzy matching rule as an example, clear and unique matching success determination criteria are formulated for the two modes respectively, making the logic of sequential matching more rigorous and the verification result more accurate.
[0044] In a possible implementation manner, the matching rule includes a first matching mode and a second matching mode; The electronic device sequentially matches each expected text content in the expected text content sequence with the text content sequence to be verified based on the preset matching rules, including: When the matching rule is the first matching mode and the current text content to be verified in the text content sequence to be verified includes the current expected text content in the expected text content sequence, the electronic device determines that the match is successful; When the matching rule is the second matching mode and the current text content to be verified in the text content sequence to be verified is the same as the current expected text content in the expected text content sequence, the electronic device determines that the match is successful.
[0045] Before performing sequential matching, the electronic device will first retrieve the pre-set matching rules or the matching rules specified by the command line parameters to determine whether the first matching mode or the second matching mode is currently in use. After determining the criteria for successful matching of a single text content, it will then follow the core principle of sequential matching to extract the current expected text content pointed to by the current pointer in the expected text content sequence, as well as the current text content to be verified pointed to by the current pointer in the text content sequence to be verified, and carry out the matching judgment of a single content.
[0046] When the matching rule is the first matching mode (i.e., consistent matching rule), the electronic device will perform a complete consistency check on the current expected text content and the current text content to be checked. It will check all details such as characters, format, and expression of the two text contents one by one. Only when the text contents of the two are completely identical and have no difference will the matching of this single content be determined to be successful; if there are any differences in characters, format, etc., the matching will be directly determined to be unsuccessful.
[0047] When the matching rule is the second matching mode (i.e., fuzzy matching rule), the electronic device does not need to perform a complete consistency check on the two text contents, but only needs to check the inclusion relationship: determine whether the current text content to be checked includes the current expected text content, that is, whether the current expected text content is a substring of the current text content to be checked. As long as this inclusion relationship is satisfied, even if the current text content to be checked contains other non-critical text information, the matching of this single content is still considered successful, adapting to scenarios that allow inconsistencies in non-critical content and only check the order of critical steps.
[0048] Regardless of whether the first or second matching mode is used, the electronic device maintains the overall sequential matching logic. After completing the matching judgment of a single piece of content, if the match is successful, the pointers of both sequences are moved forward simultaneously to continue matching the next expected text content. If the match fails, only the pointer of the text content sequence to be verified is moved forward, and the current expected text content is used to match the subsequent text content to be verified until the expected text content sequence is traversed or the text content sequence to be verified is traversed.
[0049] To further enhance the logicality and executableness of the sequential matching process between the expected and the text content sequence to be verified, and to ensure that the matching operation proceeds in sequence and efficiently, this application embodiment also clarifies the specific execution flow of sequential matching through the initialization of dual pointers and dynamic movement rules. This makes the execution logic of the entire matching process clearer and can accurately determine whether there is a successfully matched sequence in the sequence to be verified that meets the expected order.
[0050] In one possible implementation, the electronic device, based on a preset matching rule, sequentially matches each expected text content in the expected text content sequence with the text content sequence to be verified, including: The electronic device initializes a first pointer to the current expected text content to be matched in the expected text content sequence, and initializes a second pointer to the current text content to be matched in the text content sequence to be verified; The electronic device determines, according to the matching rules, whether the text content to be verified currently pointed to by the second pointer matches the expected text content currently pointed to by the first pointer; if the match is successful, both the first and second pointers are moved simultaneously; if the match fails, the second pointer is moved. Repeat the matching judgment and pointer movement steps until all expected text content in the expected text content sequence is successfully matched, or the text content sequence to be verified has been traversed.
[0051] Before performing sequential matching operations, electronic devices first initialize two pointers, creating a first pointer pointing to the expected text content sequence and a second pointer pointing to the text content sequence to be verified. Initially, the first pointer points to the first content to be matched in the expected text content sequence, and the second pointer points to the first content to be matched in the text content sequence to be verified. By identifying the positions of the two pointers, the specific object of the current matching operation is clearly defined, laying the foundation for subsequent sequential matching.
[0052] After pointer initialization, the electronic device uses preset matching rules to match the expected text content currently pointed to by the first pointer with the text content to be verified currently pointed to by the second pointer, accurately determining whether they meet the preset matching requirements. Based on the matching result, the electronic device executes the corresponding pointer movement operation. If the matching is successful, it means that the content at the current position of the sequence to be verified matches the content at the current position of the expected sequence. In this case, both the first and second pointers are moved one position to the right, and the matching object is switched to the next content of the two sequences, continuing the subsequent matching operation. If the matching fails, only the second pointer is moved one position to the right, keeping the position of the first pointer unchanged, and the current expected text content is used to match the next content of the sequence to be verified.
[0053] The electronic device will repeatedly execute the matching judgment and pointer movement steps described above. The entire process strictly follows the original order of the expected text content sequence, without disrupting the verification logic of key steps, until any traversal termination condition is triggered. If the first pointer moves to the end of the expected text content sequence, it means that all content in the expected sequence has been successfully matched in order, and there is a successfully matched sequence in the sequence to be verified. If the second pointer moves to the end of the text content sequence to be verified first, but the first pointer has not yet traversed the expected sequence, it means that there is no content in the sequence to be verified that meets the expected order, and the matching operation terminates.
[0054] S103: The electronic device outputs the matching result.
[0055] After completing the sequential matching operation and triggering any traversal termination condition, the electronic device first determines the core matching result based on the type of termination condition, and then executes the output operation according to the standardized rules. If the termination condition is that the first pointer traverses to the end of the expected text content sequence, it means that there is a successfully matched sequence in the text content sequence to be verified that matches the expected sequence order. The electronic device will determine that the match is successful, and at this time, it will immediately print a matching success message on the command line interface, and return a standardized status code 0 according to preset rules. This status code can be directly recognized by automated scripts, CI / CD pipelines, and other programs. If the termination condition is that the second pointer traverses to the end of the text content sequence to be verified first, but the first pointer still has unmatched expected text content, the electronic device will determine that the match has failed. It will first print the core conclusion of the matching failure, and then accurately output the specific unmatched expected text content, clearly informing the user of the key steps missing in the sequence to be verified, and return a standardized status code 1.
[0056] The electronic device supports multiple formats of matching result output to adapt to different application scenarios, while maintaining consistency across all output formats. In addition to the basic command-line instant printing format, allowing users to quickly obtain intuitive results through the interface, the matching results can also be completely written to a pre-set local log file, recording information such as matching time, matching mode, core conclusions, and unmatched content. This facilitates subsequent verification process tracing, problem review, and data statistics. Meanwhile, standardized status code output is one of the core formats. This format eliminates the need for manual text parsing; third-party programs or automated scripts can determine the matching result and execute subsequent automated processes simply by recognizing status codes 0 or 1, allowing the entire matching method to seamlessly integrate into various automated systems. Regardless of the output format used, the electronic device ensures the simplicity and accuracy of the results, highlighting the main conclusions, providing precise auxiliary information, and eliminating redundant content.
[0057] Based on the above embodiments, this application also provides a key step sequence matching device, such as... Figure 2 As shown, the device includes: The acquisition module 201 is used to acquire the expected text content sequence and the text content sequence to be verified; The matching module 202 is used to match each expected text content in the expected text content sequence with the text content sequence to be verified in sequence according to a preset matching rule, and to determine whether there is a successful matching sequence in the text content sequence to be verified that is consistent with the order of the expected text content sequence. Output module 203 is used to output the matching results.
[0058] In one possible implementation, the matching rules include a first matching pattern and a second matching pattern; The matching module 202 is specifically used to determine a successful match when the matching rule is the first matching mode and the current text content to be verified in the text content sequence to be verified includes the current expected text content in the expected text content sequence; and to determine a successful match when the matching rule is the second matching mode and the current text content to be verified in the text content sequence to be verified is the same as the current expected text content in the expected text content sequence.
[0059] In one possible implementation, the matching module 202 is specifically used to initialize a first pointer pointing to the current expected text content to be matched in the expected text content sequence, and initialize a second pointer pointing to the current expected text content to be matched in the text content sequence to be verified; according to the matching rules, determine whether the text content to be verified currently pointed to by the second pointer matches the expected text content currently pointed to by the first pointer; if the match is successful, move both the first pointer and the second pointer simultaneously; if the match fails, move the second pointer; repeat the matching judgment and pointer movement steps until all expected text content in the expected text content sequence is successfully matched, or the text content sequence to be verified has been traversed.
[0060] In one possible implementation, the matching rule is specified via command-line arguments; The acquisition module 201 is specifically used to parse the command line parameters to acquire a first file path parameter, a second file path parameter, and a mode parameter for indicating the matching mode; wherein, the first file path parameter is used to indicate the source of the expected text content sequence; the second file path parameter is used to indicate the source of the text content sequence to be verified; the mode parameter is used to indicate the matching mode; the file is read according to the first file path parameter to generate the expected text content sequence; the file is read according to the second file path parameter to generate the text content sequence to be verified.
[0061] In one possible implementation, the command-line parameters further include a regular expression parameter for indicating whether regular expression matching is enabled; when regular expression matching is enabled, a successful match includes: the current text content to be verified in the sequence of text content to be verified matches the regular expression represented by the current expected text content in the sequence of expected text content.
[0062] In one possible implementation, the output module 203 is specifically used to output a first status code indicating successful matching if all expected text content in the expected text content sequence is matched successfully in sequence; and to output a second status code indicating failed matching and information about the unmatched expected text content if there is unmatched expected text content.
[0063] In one possible implementation, the output module 203 is specifically used to output the position information and / or content of the unmatched expected text content in the expected text content sequence.
[0064] This application also provides a control device. The control device may include a memory and a processor. The processor is used to execute the key step sequence matching method described in any of the above embodiments. The memory may be random access memory (RAM), flash memory, read-only memory (ROM), non-volatile read-only memory (EPROM), registers, hard disk, removable disk, etc.
[0065] Memory can store computer instructions, which, when executed by the processor, can be used to perform key step sequence matching methods. Memory can also store data.
[0066] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. A computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the flow or function according to the embodiments of this application is generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape) or a semiconductor medium (e.g., solid-state disk (SSD)).
[0067] This application also provides a readable storage medium for storing the methods provided in the above embodiments. For example, RAM, flash memory, ROM, EPROM, registers, hard disk, removable disk, or any other form of storage medium in the art.
[0068] In the embodiments of this application, the terms "first" and "second" (if they exist) are used only as name identifiers and do not represent the order of first and second.
[0069] It should be noted that the various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. Regarding the methods disclosed in the embodiments, since they correspond to the product embodiments disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the description of the product embodiments.
[0070] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for matching the sequence of key steps, characterized in that, include: Obtain the expected text content sequence and the text content sequence to be verified; Based on preset matching rules, each expected text content in the expected text content sequence is matched with the text content sequence to be verified in sequence to determine whether there is a successful matching sequence in the text content sequence to be verified that is consistent with the order of the expected text content sequence. Output the matching results.
2. The method according to claim 1, characterized in that, The matching rules include a first matching pattern and a second matching pattern; The step of matching each expected text content in the expected text content sequence with the text content sequence to be verified in sequence according to a preset matching rule includes: When the matching rule is the first matching mode, and the current text content to be verified in the text content sequence to be verified includes the current expected text content in the expected text content sequence, it is determined that the match is successful; When the matching rule is the second matching mode, and the current text content to be verified in the text content sequence to be verified is the same as the current expected text content in the expected text content sequence, the match is determined to be successful.
3. The method according to claim 1, characterized in that, The step of matching each expected text content in the expected text content sequence with the text content sequence to be verified in sequence according to a preset matching rule includes: Initialize a first pointer pointing to the current expected text content to be matched in the expected text content sequence, and initialize a second pointer pointing to the current text content to be matched in the text content sequence to be verified; According to the matching rules, determine whether the text content to be verified currently pointed to by the second pointer matches the expected text content currently pointed to by the first pointer; If a match is found, both the first pointer and the second pointer are moved simultaneously. If a match fails, move the second pointer; Repeat the matching judgment and pointer movement steps until all expected text content in the expected text content sequence is successfully matched, or the text content sequence to be verified has been traversed.
4. The method according to claim 2, characterized in that, The matching rules are specified via command-line arguments; The process of obtaining the expected text content sequence and the text content sequence to be verified includes: The command-line parameters are parsed to obtain a first file path parameter, a second file path parameter, and a pattern parameter indicating the matching pattern; wherein, the first file path parameter is used to indicate the source of the expected text content sequence; the second file path parameter is used to indicate the source of the text content sequence to be verified; and the pattern parameter is used to indicate the matching pattern. The file is read according to the first file path parameter, and the expected text content sequence is generated. The file is read according to the second file path parameter, and the sequence of text content to be verified is generated.
5. The method according to claim 4, characterized in that, The command-line parameters also include regular expression parameters to indicate whether regular expression matching is enabled; when regular expression matching is enabled, a successful match includes: The current text content to be verified in the sequence of text content to be verified matches the regular expression represented by the current expected text content in the sequence of expected text content.
6. The method according to any one of claims 1 to 5, characterized in that, The output matching results include: If all expected text contents in the expected text content sequence are matched successfully in sequence, then the first status code indicating a successful match is output. If there is unmatched expected text content, output a second status code indicating a failed match, along with information about the unmatched expected text content.
7. The key step sequence matching method according to claim 6, characterized in that, Output information about the expected text content that failed to match, including: Output the position information and / or content of the unmatched expected text content in the expected text content sequence.
8. A key step sequence matching device, characterized in that, The device includes: The acquisition module is used to acquire the expected text content sequence and the text content sequence to be verified; The matching module is used to match each expected text content in the expected text content sequence with the text content sequence to be verified in sequence according to a preset matching rule, and to determine whether there is a successful matching sequence in the text content sequence to be verified that is consistent with the order of the expected text content sequence. The output module is used to output the matching results.
9. A control device, characterized in that, It includes a processor and a memory, the memory being used to store programs, instructions, or code, and the processor being used to execute the programs, instructions, or code in the memory to perform the key step sequence matching method as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The system contains a computer program that is loaded by a processor to execute the key step sequence matching method as described in any one of claims 1-7.