CN112989762A - Socket protocol-based complex character string pattern matching method - Google Patents
Socket protocol-based complex character string pattern matching method Download PDFInfo
- Publication number
- CN112989762A CN112989762A CN202110314658.XA CN202110314658A CN112989762A CN 112989762 A CN112989762 A CN 112989762A CN 202110314658 A CN202110314658 A CN 202110314658A CN 112989762 A CN112989762 A CN 112989762A
- Authority
- CN
- China
- Prior art keywords
- string
- circulation
- template
- self
- parameter
- 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.)
- Granted
Links
Images
Classifications
-
- 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
Abstract
The invention provides a Socket protocol-based complex character string pattern matching method, which relates to the technical field of computers and comprises the following steps: defining a template string and a cache structure body of the parameter string, wherein the template string comprises parameter names, and all the parameter names and corresponding parameter values are stored in the cache structure body; acquiring a self-circulation template string in the template string, analyzing parameters to be spliced contained in parameter names in the self-circulation template string, and recording the number of the parameters; taking out parameter values corresponding to all splicing parameters from the cache structure body; according to the number of the parameters, sequentially splicing the parameter values to obtain a self-circulation character string; and splicing the self-circulation character string and the rest part of the template string to obtain the target character string. According to the invention, the data which is originally acquired through one piece of hard coding is changed into the data which is acquired through the template circulation through the pattern matching method, developers do not need to analyze each parameter type one by one, and the development efficiency is improved.
Description
Technical Field
The invention relates to the technical field of computers, in particular to a complex character string pattern matching method based on a Socket protocol.
Background
Although the string matching algorithm has been developed for decades, a very practical algorithm is developed in recent years, the research on the string matching problem is disjointed between theoretical research and practical application, a scholars specialized in the algorithm research are concerned about the theoretically wonderful algorithm, and developers pursue the algorithm as fast as possible in the practical application, so that the algorithm (such as the BNDM algorithm) combining the theoretical research and the practical application is developed only in recent years and is still in the development stage.
At present, in the data interaction process between each bank and a peripheral system, because the bills of each bank system are arranged differently, when the data content is transmitted, codes need to be written to acquire data information item by item, and the data information has the characteristics of large data volume and strong data formatting.
When the traditional string matching method is adopted to match complex character strings, hard coding is needed to acquire each parameter value, so that the problems of large development workload and low development efficiency of developers are caused, different document information matching is realized, and due to the fact that the parameter names in documents are different and the arrangement sequence is different, recoding is needed, the matching method of the complex character strings needs to be provided urgently, and the development efficiency is improved.
Disclosure of Invention
Aiming at the problems, the invention provides a complex character string pattern matching method based on a Socket protocol, which completes matching and splicing of a multi-nested multi-cycle complex structure character string by configuring a template.
In order to achieve the above object, the present invention provides a method for repairing abnormal business handling according to change of fees, comprising:
defining a template string and a cache structure body of the parameter string, wherein the template string comprises parameter names, and the cache structure body stores all the parameter names and corresponding parameter values;
acquiring a self-circulation template string in the template string, analyzing parameters to be spliced contained in parameter names in the self-circulation template string, and recording the number of the parameters;
taking out parameter values corresponding to all splicing parameters from the cache structure body;
according to the number of the parameters, sequentially splicing the parameter values to obtain a self-circulation character string;
and splicing the self-circulation character string and the rest part of the template string to obtain a target character string.
As a further improvement of the invention, a temporary structure array is defined in the cache structure of the parameter string, and the parameter values corresponding to the splicing parameters taken out from the cache structure are put into the temporary structure array.
As a further improvement of the invention, the temporary structure array is traversed according to the number of the parameters, and the parameter values are sequentially spliced to obtain the self-circulation character string.
As a further improvement of the invention, the loop times of a plurality of parameters in the same self-loop character string are the same.
As a further improvement of the present invention, when the number of parameters to be spliced contained in each parameter name in the self-circulation template string is different, the number of circulation times of the self-circulation template string is small.
As a further improvement of the invention, the template string comprises separators, the separators comprise a start character and an end character, and a self-circulation template string is arranged between the start character and the end character.
As a further improvement of the present invention, when acquiring the self-circulation template string in the template string, it is first determined whether the template string includes a start character, if so, it is further determined whether the template string includes an end character,
and if the end separator is also included, acquiring the template string between the start separator and the end separator as a self-circulation template string.
As a further improvement of the present invention, if the start symbol is not included, returning and ending the loop; if the end separator is not included, the loop is skipped and the next loop is entered.
As a further improvement of the invention, a counter is defined to count the number of parameters to be spliced contained in each parameter name in the self-circulation template string.
As a further development of the invention, the length of the parameter is noted after the parameter name in the template string.
Compared with the prior art, the invention has the beneficial effects that:
the data which is originally acquired through one piece of hard coding is changed into the data which is acquired through the template circulation through the pattern matching method, developers do not need to analyze each parameter type one by one, only the configuration is needed in the template, and the development efficiency of the developers is improved.
The template string in the pattern matching method is good in universality, can be suitable for character strings of a plurality of socket messages, is easy to maintain, and can be directly modified without modifying codes when the parameter types and the sequence need to be modified or adjusted.
Drawings
Fig. 1 is a flowchart of a complex string pattern matching method based on a Socket protocol according to an embodiment of the present invention;
fig. 2 is a block diagram of a template string matching and splicing process according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be obtained by a person skilled in the art without any inventive step based on the embodiments of the present invention, are within the scope of the present invention.
The invention is described in further detail below with reference to the attached drawing figures:
as shown in fig. 1, the complex string pattern matching method based on the Socket protocol provided by the present invention includes:
s1, defining a template string and a cache structure body of the parameter string, wherein the template string comprises parameter names, and all the parameter names and corresponding parameter values are stored in the cache structure body;
wherein the content of the first and second substances,
the length of a parameter is noted after the parameter name in the template string.
And defining a temporary structure array in the cache structure of the parameter string, and taking out the parameter values corresponding to all splicing parameters from the cache structure and putting the parameter values into the temporary structure array.
Traversing the temporary structure array according to the number of the parameters, and sequentially splicing the parameter values to obtain a self-circulation character string.
S2, acquiring a self-circulation template string in the template string, analyzing parameters to be spliced contained in parameter names in the self-circulation template string as shown in FIG. 2, and recording the number of the parameters;
wherein the content of the first and second substances,
the template string comprises separators which comprise a start character and an end character, and a self-circulation template string is arranged between the start character and the end character; when the self-circulation template string in the template string is obtained, firstly, judging whether the template string comprises a start character or not, if so, further judging whether the template string comprises an end character or not,
if an end separator is also included, the template string between the start separator and the end separator is obtained as a self-looping template string.
If the start character is not included, returning and ending the circulation; if the end separator is not included, the loop is skipped and the next loop is entered.
In addition, the circulation times of a plurality of parameters in the same self-circulation character string are the same; counting the number of parameters to be spliced contained in each parameter name in the self-circulation template string by using a definition counter, wherein when the number of the parameters to be spliced contained in each parameter name in the self-circulation template string is different, the circulation times of the self-circulation template string are less.
S3, taking out the parameter values corresponding to the splicing parameters from the cache structure body;
s4, sequentially splicing the parameter values according to the number of the parameters to obtain a self-circulation character string;
and S5, splicing the self-circulation character string and the rest part of the template string to obtain a target character string.
Example (b):
the method can be applied to the analysis and splicing scenes with fixed character string positions, various protocol adapters based on the socket protocol can use the technology, and the protocol definition of the H2 protocol adapter is as follows: the method adopts a standard socket protocol to carry out short-connection synchronous communication and adopts an ASCII Stream (STREM) mode oriented to stable connection. Taking the H2 protocol adapter as an example, the complex string pattern matching when acquiring the interactive data is as follows:
step 1, defining a cache structure body of a template string and a parameter string;
firstly, information interaction is carried out between the money information of a certain bank and a peripheral system, and the information needing to be acquired circularly is as follows:
name of field | Length of field | Description of the format |
Contract number | 20 | |
User name | 60 | |
1 | 0x0A recording separators | |
Serial number | 2 | |
Expense item name 1 | 20 | Character(s) |
Amount of charge 1 | 10 | Character(s) |
Expense item name 2 | 20 | Character(s) |
Amount of charge 2 | 10 | Character(s) |
1 | 0x0A recording separators | |
1 | 0x1A end of package sign |
Other remaining parts to be configured:
according to the above information, the information to be cyclically acquired is written into the self-circulation template string, and other remaining parts to be configured are also written into the template string, as follows:
%VERSION(2)%%PKG_LENGTH(5)%%SEQUEUE(20)%%RETN_FLAG(1)%%SERVICE_FLAG(12)%%SERVICE_NUMBER(20)%NUMBER_TYPE(1)%%LOGIN_NO(6)%%LOGIN_ADDR(6)%%PKG_NUMBER(5)%%LAST_FLAG(1)%%ERRNO(5)%%BALANCE_CODE(20)%%USER_NAME(60)%%ICOUNT(2)%{///%FEE_NAME(20)%%FEE_NUMBER(10)%///}
wherein,%% is separators, VERSION, PKG _ LENGTH, SEQUEUE and the like between the separators are parameter names, and the number in brackets after the parameter names is the LENGTH of the parameters;
the part enclosed by {////// } is the start character and/or the end character represents the self-loop template string, and there are multiple loops.
Then, defining a cache structure of the parameter string:
the acParaName stores the name of each parameter in the template string, and the acParaValue stores the specific value of the parameter in the template string.
Then, a temporary structure array is defined, and the maximum parameter number of the array is defined.
# define MAXPARA 100/. maximum parameter number. sup
STRWCORKPARA STRWORKPARA [ MAXPARA ]; /' parameter string array
Step 2, obtaining a self-circulation template string in the template string, analyzing parameters to be spliced contained in parameter names in the self-circulation template string, and recording the number of the parameters;
the self-circulation template string is as follows:
{///%FEE_NAME(20)%%FEE_NUMBER(10)%///}
the FEE _ NAME is of the form a1| a2| a 3; FEE _ NUMBER is of the form b1| b2| b 3;
wherein | is a separator, recording data a1, a2, a3, b1, b2, b3 which are | separated;
recording the number of parameters which are separated by | in each parameter name, wherein the number of the parameters is 3, and the cycle times are the same;
step 3, taking out the parameter values corresponding to the splicing parameters from the cache structure body, and respectively placing the parameter values into the temporary structure body array tmprar;
step 4, traversing the tmprar arrays according to the number of the parameters which are 3, and sequentially splicing the parameter values to obtain a self-circulation character string; the shape is as follows: a1 b1a2 b2a 3b 3;
and 5, splicing the self-circulation character string and the rest part of the template string to obtain a target character string.
The invention has the advantages that:
the data which is originally acquired through one piece of hard coding is changed into the data which is acquired through the template circulation through the pattern matching method, developers do not need to analyze each parameter type one by one, and only need to configure in the template.
The template has good universality, can adapt to the character string operation of a plurality of SOCKET messages, is easy to maintain, and only needs to adjust the parameter configuration template without modifying codes when the parameter types needing to be matched need to be modified or adjusted.
The above is only a preferred embodiment of the present invention, and is not intended to limit the present invention, and various modifications and changes will occur to those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims (10)
1. A complex character string pattern matching method based on a Socket protocol is characterized by comprising the following steps:
defining a template string and a cache structure body of the parameter string, wherein the template string comprises parameter names, and the cache structure body stores all the parameter names and corresponding parameter values;
acquiring a self-circulation template string in the template string, analyzing parameters to be spliced contained in parameter names in the self-circulation template string, and recording the number of the parameters;
taking out parameter values corresponding to all splicing parameters from the cache structure body;
according to the number of the parameters, sequentially splicing the parameter values to obtain a self-circulation character string;
and splicing the self-circulation character string and the rest part of the template string to obtain a target character string.
2. The method of claim 1, wherein: and defining a temporary structure array in the cache structure of the parameter string, and putting the parameter values corresponding to the splicing parameters taken out of the cache structure into the temporary structure array.
3. The method of claim 2, wherein: traversing the temporary structure array according to the number of the parameters, and sequentially splicing the parameter values to obtain a self-circulation character string.
4. The method of claim 1, wherein: and the circulation times of the parameters in the same self-circulation character string are the same.
5. The method according to claim 1 or 4, characterized in that: and when the number of the parameters to be spliced contained in each parameter name in the self-circulation template string is different, the circulation times of the self-circulation template string are subject to less.
6. The method of claim 1, wherein: the template string comprises separators, each separator comprises a start character and an end character, and a self-circulation template string is arranged between the start characters and the end characters.
7. The method of claim 6, wherein: when the self-circulation template string in the template string is obtained, firstly, judging whether the template string comprises a start character or not, if so, further judging whether the template string comprises an end character or not,
and if the end separator is also included, acquiring the template string between the start separator and the end separator as a self-circulation template string.
8. The method of claim 7, wherein: if the start character is not included, returning and ending the circulation; if the end separator is not included, the loop is skipped and the next loop is entered.
9. The method of claim 1, wherein: and the number of parameters to be spliced contained in each parameter name in the self-circulation template string is counted by a definition counter.
10. The method of claim 1, wherein: the length of the parameter is noted after the parameter name in the template string.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110314658.XA CN112989762B (en) | 2021-03-24 | 2021-03-24 | Complex character string pattern matching method based on Socket protocol |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110314658.XA CN112989762B (en) | 2021-03-24 | 2021-03-24 | Complex character string pattern matching method based on Socket protocol |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112989762A true CN112989762A (en) | 2021-06-18 |
CN112989762B CN112989762B (en) | 2023-08-25 |
Family
ID=76333417
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110314658.XA Active CN112989762B (en) | 2021-03-24 | 2021-03-24 | Complex character string pattern matching method based on Socket protocol |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112989762B (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114285906A (en) * | 2021-12-24 | 2022-04-05 | 北京天融信网络安全技术有限公司 | Message processing method and device, electronic equipment and storage medium |
Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6039245A (en) * | 1996-06-10 | 2000-03-21 | Diebold, Incorporated | Financial transaction processing system and method |
CN105721154A (en) * | 2014-12-05 | 2016-06-29 | 航天信息股份有限公司 | Encryption protection method based on Android platform communication interface |
CN106951255A (en) * | 2017-03-23 | 2017-07-14 | 福建中金在线信息科技有限公司 | A kind of processing method and processing device of splicing character string |
CN107870765A (en) * | 2016-09-26 | 2018-04-03 | 平安科技(深圳)有限公司 | Message joining method and terminal |
CN108881125A (en) * | 2017-05-15 | 2018-11-23 | 武汉斗鱼网络科技有限公司 | Parse method, storage medium, equipment and the system of communication protocol |
CN111078573A (en) * | 2019-12-24 | 2020-04-28 | 深圳前海微众银行股份有限公司 | Test message generation method and device |
CN112328231A (en) * | 2020-10-14 | 2021-02-05 | 远江盛邦(北京)网络安全科技股份有限公司 | Quick conversion method between python dictionary and structure |
CN112330202A (en) * | 2020-11-25 | 2021-02-05 | 中盈优创资讯科技有限公司 | Control intention work order module based on arranging control flow service fulfillment |
-
2021
- 2021-03-24 CN CN202110314658.XA patent/CN112989762B/en active Active
Patent Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6039245A (en) * | 1996-06-10 | 2000-03-21 | Diebold, Incorporated | Financial transaction processing system and method |
CN105721154A (en) * | 2014-12-05 | 2016-06-29 | 航天信息股份有限公司 | Encryption protection method based on Android platform communication interface |
CN107870765A (en) * | 2016-09-26 | 2018-04-03 | 平安科技(深圳)有限公司 | Message joining method and terminal |
CN106951255A (en) * | 2017-03-23 | 2017-07-14 | 福建中金在线信息科技有限公司 | A kind of processing method and processing device of splicing character string |
CN108881125A (en) * | 2017-05-15 | 2018-11-23 | 武汉斗鱼网络科技有限公司 | Parse method, storage medium, equipment and the system of communication protocol |
CN111078573A (en) * | 2019-12-24 | 2020-04-28 | 深圳前海微众银行股份有限公司 | Test message generation method and device |
CN112328231A (en) * | 2020-10-14 | 2021-02-05 | 远江盛邦(北京)网络安全科技股份有限公司 | Quick conversion method between python dictionary and structure |
CN112330202A (en) * | 2020-11-25 | 2021-02-05 | 中盈优创资讯科技有限公司 | Control intention work order module based on arranging control flow service fulfillment |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114285906A (en) * | 2021-12-24 | 2022-04-05 | 北京天融信网络安全技术有限公司 | Message processing method and device, electronic equipment and storage medium |
CN114285906B (en) * | 2021-12-24 | 2024-01-23 | 北京天融信网络安全技术有限公司 | Message processing method and device, electronic equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN112989762B (en) | 2023-08-25 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US9934233B2 (en) | Searchable data archive | |
CN103294652B (en) | A kind of data transfer device and system | |
CN109670081A (en) | The method and device of service request processing | |
CN105913233A (en) | SDK processing method suitable for application client end payment | |
CN103927314B (en) | A kind of method and apparatus of batch data processing | |
CN102567534B (en) | Interactive product user generated content intercepting system and intercepting method for the same | |
CN106557470A (en) | data extraction method and device | |
CN105045676B (en) | A kind of restoration methods of the loss data based on SQLite databases | |
CN109753517A (en) | A kind of method, apparatus, computer storage medium and the terminal of information inquiry | |
CN112989762A (en) | Socket protocol-based complex character string pattern matching method | |
CN109461066A (en) | Electric power enterprise reconciliation system and method | |
CN109598575B (en) | Bill generation method and device, electronic equipment and medium | |
WO2012079387A1 (en) | Method for using short messages and apparatus | |
CN102348186A (en) | Account and asset loader tool | |
JP2001307008A (en) | Form image processor | |
CN112506869A (en) | File processing method, device and system | |
CN105207807B (en) | A kind of SIM card flow analysis method applied to power information acquisition system | |
CN109697224B (en) | Bill message processing method, device and storage medium | |
CN111143554B (en) | Data sampling method and device based on big data platform | |
CN107395418A (en) | Statistical processing methods, system and the server of network behavior data | |
CN115129948A (en) | Complex character string pattern matching method and system, electronic equipment and storage medium | |
AU2019404304A1 (en) | Gain and loss computation for cryptocurrency transactions | |
CN110288469A (en) | A kind of token automatic distributing method, apparatus and computer equipment | |
CN113506359A (en) | Animation element acquisition method and device | |
CN115439128A (en) | Third-party payment platform-oriented fraud identification method and device |
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 |