CN116304219A - Character string empty judging method and device, electronic equipment and storage medium - Google Patents

Character string empty judging method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN116304219A
CN116304219A CN202211105377.4A CN202211105377A CN116304219A CN 116304219 A CN116304219 A CN 116304219A CN 202211105377 A CN202211105377 A CN 202211105377A CN 116304219 A CN116304219 A CN 116304219A
Authority
CN
China
Prior art keywords
character string
character
judged
empty
judging
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.)
Pending
Application number
CN202211105377.4A
Other languages
Chinese (zh)
Inventor
田振
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Chery Automobile Co Ltd
Wuhu Lion Automotive Technologies Co Ltd
Original Assignee
Chery Automobile Co Ltd
Wuhu Lion Automotive Technologies Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Chery Automobile Co Ltd, Wuhu Lion Automotive Technologies Co Ltd filed Critical Chery Automobile Co Ltd
Priority to CN202211105377.4A priority Critical patent/CN116304219A/en
Publication of CN116304219A publication Critical patent/CN116304219A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/903Querying
    • G06F16/90335Query processing
    • G06F16/90344Query processing by using string matching techniques
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/12Use of codes for handling textual entities
    • G06F40/126Character encoding
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/12Use of codes for handling textual entities
    • G06F40/151Transformation

Abstract

The present application relates to the field of character string matching technologies, and in particular, to a method, an apparatus, an electronic device, and a storage medium for determining null of a character string, where the method includes: judging whether the length of the character string to be judged is 0; if the character string length is not 0, splitting the character string to be judged into a plurality of character arrays; traversing each character array, converting characters in each character array into int types, obtaining a plurality of integer characters, converting the integer characters into a plurality of ASCII code table code values, and judging that the character string to be judged is empty when the ASCII code table code values meet the preset empty judgment condition. Therefore, the problem that the null judgment method in the related technology does not contain special characters is solved, the judgment standard for the special characters is additionally increased, and the adaptability of null judgment of the character strings is improved.

Description

Character string empty judging method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of character string matching technologies, and in particular, to a method, an apparatus, an electronic device, and a storage medium for determining null of a character string.
Background
Character string matching is a fundamental problem of computer science, and methods for solving the problem of character string matching are widely cited into text editing, search engines, and advanced programming language compilers.
The conventional art of judging whether a character string is empty follows the following manner: (1) the string is NULL or NULL; (2) judging whether the character string length is 0; and (3) calling the JDK self-contained character string to judge the blank class.
However, some special characters such as a space, tab key, line feed, unicode space character, error character, special character '_202a', etc. are not judged in the related art.
Disclosure of Invention
The application provides a method, a device, electronic equipment and a storage medium for judging the blank of a character string, which are used for solving the problem that the blank judging method in the related technology does not contain special characters, additionally adding judging standards for the special characters and improving the adaptability of the blank judging of the character string.
An embodiment of a first aspect of the present application provides a null judgment method for a character string, including the following steps: judging whether the length of the character string to be judged is 0; if the character string length is not 0, splitting the character string to be judged into a plurality of character arrays; traversing each character array, converting characters in each character array into int types, obtaining a plurality of integer characters, converting the integer characters into a plurality of ASCII (American Standard Code for Information Interchange, american information interchange standard code) code table code values, and judging that the character string to be judged is empty when the ASCII code table code values meet a preset empty judgment condition.
Optionally, in some embodiments, the preset air judgment condition is: the code values of the ASCII code tables are equal to the code value of any ASCII code in space, tab key, line feed, unicode space character, error character '_foff', special Unicode character '_202 a'.
Optionally, in some embodiments, before the determining whether the length of the string to be determined is 0, the method further includes: judging whether the character string to be judged is an empty character string or not; if the character string to be judged is the empty character string, directly returning to the character string to be judged to be empty; otherwise, judging whether the length of the character string to be judged is 0.
Optionally, in some embodiments, when the plurality of target code values do not meet the empty judgment condition, the character string to be judged is judged not to be empty.
An embodiment of a second aspect of the present application provides a null judgment device for a character string, including: the judging module is used for judging whether the length of the character string to be judged is 0; the splitting module is used for splitting the character string to be judged into a plurality of character arrays if the length of the character string is not 0; the judging module is used for traversing each character array, converting the characters in each character array into the int type, obtaining a plurality of integer characters, converting the integer characters into a plurality of ASCII code table code values, and judging that the character string to be judged is empty when the ASCII code table code values meet the preset empty judging condition.
Optionally, in some embodiments, the preset air judgment condition is: the code values of the ASCII code tables are equal to the code value of any ASCII code in space, tab key, line feed, unicode space character, error character '_foff', special Unicode character '_202 a'.
Optionally, in some embodiments, before the determining whether the length of the string to be determined is 0, the determining module further includes: judging whether the character string to be judged is an empty character string or not; if the character string to be judged is the empty character string, directly returning to the character string to be judged to be empty; otherwise, judging whether the length of the character string to be judged is 0.
Optionally, in some embodiments, when the plurality of target code values do not meet the empty judgment condition, the character string to be judged is judged not to be empty.
An embodiment of a third aspect of the present application provides an electronic device, including: the device comprises a memory, a processor and a computer program stored in the memory and capable of running on the processor, wherein the processor executes the program to realize the method for judging the empty of the character string.
An embodiment of the fourth aspect of the present application provides a computer-readable storage medium having stored thereon a computer program that is executed by a processor to implement the method for determining null of a character string as described in the above embodiment.
Therefore, whether the length of the character string to be judged is 0 is judged, if the length of the character string is not 0, the character string to be judged is split into a plurality of character arrays, each character array is traversed, characters in each character array are converted into int types, a plurality of integer characters are obtained, the integer characters are converted into a plurality of ASCII code table code values, and when the ASCII code table code values meet the preset empty judging condition, the character string to be judged is judged to be empty. Therefore, the problem that the null judgment method in the related technology does not contain special characters is solved, the judgment standard for the special characters is additionally increased, and the adaptability of null judgment of the character strings is improved.
Additional aspects and advantages of the application will be set forth in part in the description which follows and, in part, will be obvious from the description, or may be learned by practice of the application.
Drawings
The foregoing and/or additional aspects and advantages of the present application will become apparent and readily appreciated from the following description of the embodiments, taken in conjunction with the accompanying drawings, in which:
fig. 1 is a flowchart of a method for determining null of a character string according to an embodiment of the present application;
FIG. 2 is a flowchart of a method for determining null of a character string according to one embodiment of the present application;
fig. 3 is a block schematic diagram of a device for determining null of a character string according to an embodiment of the present application;
fig. 4 is a schematic diagram of an electronic device according to an embodiment of the present application.
Detailed Description
Embodiments of the present application are described in detail below, examples of which are illustrated in the accompanying drawings, wherein the same or similar reference numerals refer to the same or similar elements or elements having the same or similar functions throughout. The embodiments described below by referring to the drawings are exemplary and intended for the purpose of explaining the present application and are not to be construed as limiting the present application.
The following describes a method, an apparatus, an electronic device, and a storage medium for determining null of a character string according to embodiments of the present application with reference to the accompanying drawings. In order to solve the problem that the blank judging method in the related art mentioned in the background art does not include special characters, the application provides a blank judging method for a character string, in the method, whether the length of the character string to be judged is 0 is judged, if the length of the character string is not 0, the character string to be judged is split into a plurality of character arrays, each character array is traversed, characters in each character array are converted into int types, a plurality of integer characters are obtained, the integer characters are converted into a plurality of ASCII code table code values, and when the ASCII code table code values meet preset blank judging conditions, the character string to be judged is blank. Therefore, the problem that the null judgment method in the related technology does not contain special characters is solved, the judgment standard for the special characters is additionally increased, and the adaptability of null judgment of the character strings is improved.
Specifically, fig. 1 is a flow chart of a method for determining null of a character string according to an embodiment of the present application.
As shown in fig. 1, the method for judging the blank of the character string comprises the following steps:
in step S101, it is determined whether the length of the character string to be determined is 0.
Specifically, whether the character string to be judged is 0 is judged, and if so, the character string is confirmed to be empty.
Optionally, in some embodiments, before determining whether the length of the character string to be determined is 0, the method further includes: judging whether the character string to be judged is an empty character string or not; if the character string to be judged is the empty character string, directly returning to the condition that the character string to be judged is empty; otherwise, judging whether the length of the character string to be judged is 0.
Specifically, referring to fig. 2, in the embodiment of the present application, it is determined whether the reference direction of the character string to be determined points to the keyword NULL, and if yes, the character string is confirmed to be empty; if the character string is not NULL, it is determined whether the length of the character string is 0, and if it is 0, it is confirmed that the character string is NULL.
In step S102, if the string length is not 0, the string to be determined is split into a plurality of character arrays.
Specifically, referring to fig. 2, in the embodiment of the present application, if the string length is not 0, the string to be determined may be split into a plurality of character arrays for convenience of screening.
In step S103, each character array is traversed, the characters in each character array are converted into int types, a plurality of integer characters are obtained, the integer characters are converted into a plurality of ASCII code table code values, and when the ASCII code table code values meet a preset empty judgment condition, the character string to be judged is judged to be empty.
Optionally, in some embodiments, the preset air judgment conditions are: the code values of the plurality of ASCII code tables are equal to the code value of any ASCII code of space, tab key, line feed, unicode space character, error character '_foff', special Unicode character '_202 a'.
Specifically, referring to fig. 2, after splitting a character string to be determined into a plurality of character arrays, acquiring each character, performing int type conversion on the character, and converting the character into an ASCII code value of an ASCII code comparison table; if the space, tab key, line feed character, unicode space character, error character '_foff', special Unicode character '_202a' all have corresponding values in ASCII code comparison table, all characters and the specific character types are judged to have equal ASCII code values, if the characters and the specific character types are the same, the character string is confirmed to be empty.
Optionally, in some embodiments, when the plurality of target code values do not satisfy the null judgment condition, it is judged that the character string to be judged is not null.
Specifically, as shown in fig. 2, in the embodiment of the present application, based on the original empty judgment, a technique based on conversion of a character string into an ASCII code comparison table is added to further confirm whether the character string is empty, and when a plurality of targets Ma Zhi do not satisfy the empty judgment condition, it is determined that the character string to be judged is not empty.
According to the null judgment method for the character string provided by the embodiment of the application, whether the length of the character string to be judged is 0 is judged, if the length of the character string is not 0, the character string to be judged is split into a plurality of character arrays, each character array is traversed, characters in each character array are converted into the type of int to obtain a plurality of integer characters, the integer characters are converted into a plurality of ASCII code table code values, and the character string to be judged is judged to be null when the ASCII code table code values meet the preset null judgment condition. Therefore, the problem that the null judgment method in the related technology does not contain special characters is solved, the judgment standard for the special characters is additionally increased, and the adaptability of null judgment of the character strings is improved.
Next, a null judgment device of a character string according to an embodiment of the present application will be described with reference to the accompanying drawings.
Fig. 3 is a block schematic diagram of a null-determining device for a character string according to an embodiment of the present application.
As shown in fig. 3, the null judgment device 10 of the character string includes: a decision module 100, a split module 200 and a decision module 300.
The judging module 100 is configured to judge whether the length of the character string to be judged is 0; the splitting module 200 is configured to split the character string to be judged into a plurality of character arrays if the character string length is not 0; the judging module 300 is configured to traverse each character array, convert the characters in each character array into int types, obtain a plurality of integer characters, convert the plurality of integer characters into a plurality of ASCII code table code values, and judge that the character string to be judged is blank when the plurality of ASCII code table code values satisfy a preset blank judging condition.
Optionally, in some embodiments, the preset air judgment conditions are: the code values of the plurality of ASCII code tables are equal to the code value of any ASCII code of space, tab key, line feed, unicode space character, error character '_foff', special Unicode character '_202 a'.
Optionally, in some embodiments, after acquiring the character string to be judged, the judging module 200 further includes: judging whether the character string to be judged is an empty character string or not; if the character string to be judged is the empty character string, directly returning to the condition that the character string to be judged is empty; otherwise, judging whether the length of the character string to be judged is 0.
Optionally, in some embodiments, when the plurality of target code values do not satisfy the null judgment condition, it is judged that the character string to be judged is not null.
It should be noted that the explanation of the foregoing embodiment of the method for determining the null of the character string is also applicable to the null determining device of the character string in this embodiment, and will not be repeated here.
According to the null judgment device for the character string provided by the embodiment of the application, whether the length of the character string to be judged is 0 is judged, if the length of the character string is not 0, the character string to be judged is split into a plurality of character arrays, each character array is traversed, characters in each character array are converted into the type of int to obtain a plurality of integer characters, the integer characters are converted into a plurality of ASCII code table code values, and the character string to be judged is judged to be null when the ASCII code table code values meet the preset null judgment condition. Therefore, the problem that the null judgment method in the related technology does not contain special characters is solved, the judgment standard for the special characters is additionally increased, and the adaptability of null judgment of the character strings is improved.
Fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present application. The electronic device may include:
memory 401, processor 402, and a computer program stored on memory 401 and executable on processor 402.
The processor 402 implements the null judgment method of the character string provided in the above embodiment when executing the program.
Further, the electronic device further includes:
a communication interface 403 for communication between the memory 401 and the processor 402.
A memory 401 for storing a computer program executable on the processor 402.
The memory 401 may include high speed RAM (Random Access Memory ) memory, and may also include non-volatile memory, such as at least one disk memory.
If the memory 401, the processor 402, and the communication interface 403 are implemented independently, the communication interface 403, the memory 401, and the processor 402 may be connected to each other by a bus and perform communication with each other. The bus may be an ISA (Industry Standard Architecture ) bus, a PCI (Peripheral Component, external device interconnect) bus, or EISA (Extended Industry Standard Architecture ) bus, among others. The buses may be divided into address buses, data buses, control buses, etc. For ease of illustration, only one thick line is shown in fig. 4, but not only one bus or one type of bus.
Alternatively, in a specific implementation, if the memory 401, the processor 402, and the communication interface 403 are integrated on a chip, the memory 401, the processor 402, and the communication interface 403 may perform communication with each other through internal interfaces.
The processor 402 may be a CPU (Central Processing Unit ) or ASIC (Application Specific Integrated Circuit, application specific integrated circuit) or one or more integrated circuits configured to implement embodiments of the present application.
The embodiment of the application also provides a computer readable storage medium, on which a computer program is stored, which when executed by a processor, implements the above method for determining the null of a character string.
In the description of the present specification, a description referring to terms "one embodiment," "some embodiments," "examples," "specific examples," or "some examples," etc., means that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the present application. In this specification, schematic representations of the above terms are not necessarily directed to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or N embodiments or examples. Furthermore, the different embodiments or examples described in this specification and the features of the different embodiments or examples may be combined and combined by those skilled in the art without contradiction.
Furthermore, the terms "first," "second," and the like, are used for descriptive purposes only and are not to be construed as indicating or implying a relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defining "a first" or "a second" may explicitly or implicitly include at least one such feature. In the description of the present application, the meaning of "N" is at least two, such as two, three, etc., unless explicitly defined otherwise.
Any process or method descriptions in flow charts or otherwise described herein may be understood as representing modules, segments, or portions of code which include one or more N executable instructions for implementing specific logical functions or steps of the process, and further implementations are included within the scope of the preferred embodiment of the present application in which functions may be executed out of order from that shown or discussed, including substantially concurrently or in reverse order, depending on the functionality involved, as would be understood by those reasonably skilled in the art of the embodiments of the present application.
It is to be understood that portions of the present application may be implemented in hardware, software, firmware, or a combination thereof. In the above-described embodiments, the N steps or methods may be implemented in software or firmware stored in a memory and executed by a suitable instruction execution system. As with the other embodiments, if implemented in hardware, may be implemented using any one or combination of the following techniques, as is well known in the art: discrete logic circuits having logic gates for implementing logic functions on data signals, application specific integrated circuits having suitable combinational logic gates, programmable gate arrays, field programmable gate arrays, and the like.
Those of ordinary skill in the art will appreciate that all or a portion of the steps carried out in the method of the above-described embodiments may be implemented by a program to instruct related hardware, where the program may be stored in a computer readable storage medium, and where the program, when executed, includes one or a combination of the steps of the method embodiments.
Although embodiments of the present application have been shown and described above, it will be understood that the above embodiments are illustrative and not to be construed as limiting the application, and that variations, modifications, alternatives, and variations may be made to the above embodiments by one of ordinary skill in the art within the scope of the application.

Claims (10)

1. The character string empty judging method is characterized by comprising the following steps of:
judging whether the length of the character string to be judged is 0;
if the character string length is not 0, splitting the character string to be judged into a plurality of character arrays; and
traversing each character array, converting characters in each character array into an int type, obtaining a plurality of integer characters, converting the integer characters into a plurality of ASCII code table code values, and judging that the character string to be judged is empty when the ASCII code table code values meet a preset empty judgment condition.
2. The method according to claim 1, wherein the preset empty judgment condition is:
the code values of the ASCII code tables are equal to the code value of any ASCII code in space, tab key, line feed, unicode space character, error character '_foff', special Unicode character '_202 a'.
3. The method of claim 1, further comprising, prior to determining whether the length of the string to be determined is 0:
judging whether the character string to be judged is an empty character string or not;
if the character string to be judged is the empty character string, directly returning to the character string to be judged to be empty; otherwise, judging whether the length of the character string to be judged is 0.
4. The method as recited in claim 1, further comprising:
and when the target code values do not meet the empty judgment condition, judging that the character string to be judged is not empty.
5. An empty judgment device for a character string, comprising:
the judging module is used for judging whether the length of the character string to be judged is 0;
the splitting module is used for splitting the character string to be judged into a plurality of character arrays if the length of the character string is not 0; and
the judging module is used for traversing each character array, converting the characters in each character array into the int type, obtaining a plurality of integer characters, converting the integer characters into a plurality of ASCII code table code values, and judging that the character string to be judged is empty when the ASCII code table code values meet the preset empty judging condition.
6. The apparatus of claim 5, wherein the preset empty judgment condition is:
the code values of the ASCII code tables are equal to the code value of any ASCII code in space, tab key, line feed, unicode space character, error character '_foff', special Unicode character '_202 a'.
7. The apparatus of claim 5, wherein the determining module, prior to the determining whether the length of the string to be determined is 0, further comprises:
judging whether the character string to be judged is an empty character string or not;
if the character string to be judged is the empty character string, directly returning to the character string to be judged to be empty; otherwise, judging whether the length of the character string to be judged is 0.
8. The apparatus as recited in claim 5, further comprising:
and when the target code values do not meet the empty judgment condition, judging that the character string to be judged is not empty.
9. An electronic device, comprising: a memory, a processor and a computer program stored on the memory and executable on the processor, the processor executing the program to implement the method of void determination of a string according to any one of claims 1 to 4.
10. A computer-readable storage medium, on which a computer program is stored, characterized in that the program is executed by a processor for implementing a method of void-judging a character string according to any one of claims 1-4.
CN202211105377.4A 2022-09-09 2022-09-09 Character string empty judging method and device, electronic equipment and storage medium Pending CN116304219A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211105377.4A CN116304219A (en) 2022-09-09 2022-09-09 Character string empty judging method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211105377.4A CN116304219A (en) 2022-09-09 2022-09-09 Character string empty judging method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN116304219A true CN116304219A (en) 2023-06-23

Family

ID=86798351

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211105377.4A Pending CN116304219A (en) 2022-09-09 2022-09-09 Character string empty judging method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN116304219A (en)

Similar Documents

Publication Publication Date Title
KR100458105B1 (en) Memory array having compilable address magnitude comparator for self-testing
CN117131834A (en) Chip design reorganization method, electronic equipment and medium
CN116304219A (en) Character string empty judging method and device, electronic equipment and storage medium
CN111596970B (en) Method, device, equipment and storage medium for dynamic library delay loading
CN115576603B (en) Method and device for acquiring variable values in code segment
US9201982B2 (en) Priority search trees
CN117131824A (en) Method for automatically generating chip design RTL code, electronic equipment and medium
US11416390B2 (en) Tri-color bitmap array for garbage collection
JPH09321145A (en) Layout of semiconductor integrated circuit
CN1184488C (en) Semiconductor device contg. macro and its test method
CN110543664B (en) Process mapping method for FPGA with special structure
CN112181354A (en) Method for synchronous shift saturation processing and application thereof
CN116227392B (en) Bit feature position searching method, storage medium and electronic device
CN112148706A (en) Variable grouping method and related equipment
US5889998A (en) Translation scheme from object oriented chill to chill for the visibility of the mereta mode
CN112463194B (en) File data compatible method and device, terminal equipment and storage medium
JP2585895B2 (en) Communication control device and information processing device
CN117992049A (en) JPA data conversion method and device, electronic equipment and storage medium
CN117131815A (en) Method for automatically generating chip weak drive shell, electronic equipment and medium
CN109861949B (en) Message filtering method and device and electronic equipment
JP2897737B2 (en) Logic synthesis device and logic synthesis method
CN117008959A (en) Flink-oriented data processing method, device, equipment and storage medium
CN116360770A (en) Method, device, electronic equipment and storage medium for cloning JAVA object
CN117131814A (en) Method for automatically generating chip empty shell, electronic equipment and medium
CN115729752A (en) Register checking method and device and storage medium

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