Home > Software engineering >  String processing, the subsequent improvements.
String processing, the subsequent improvements.

Time:10-25

Last time, in the BBS, I want to separate "1 x bcd_9292" such as strings, such as isolated bcd_9292 number 1 and string content, special thanks to "sysdzw" last time, help me to solve this problem, my last question, did not consider, there are several ways as follows:
ABC (1) 1 X CVA_8901, 1 X, 2 X CAD;
(2) 1 x cva202
(3) 2 x DEE15043, DEA20201: how is the separation of
(4) 2 x DEE150431 DEA20201 x
This kind of circumstance can you look at, when there is a (3) because one is not match to the quantity, have prompted; (4) in this case, x digital wrote before went to the front, also hope to have prompt,
The regular expression is absolutely powerful, but now I'm in the face of (3) and (4), want to have a prompt, (3) the number of the second sku is artificial reason didn't write; (4) was written, two strings together lead to the number of the second separation not to come out,
Thank you all!

CodePudding user response:

Regular expression mainly in the regular search string to data,
As for your requirements mainly should be a grammar testing now, recommended the split statements to test the each word is faster,

CodePudding user response:

 
Private Sub Command1_Click ()
Call Grammar (" 1 X CVA_8901, ABxC 1 X, 2 X CAD ")
End Sub


'* * * * * * * * * * * * * * * * * * * *
'the following only for [digital characters, X X characters] type of grammar tests data,
'here are given syntax compliance, cannot be wrong character period of modification for the compliance of

Private Function Grammar (ByVal strCheck As String) As Boolean
Dim I As Single
Grammar=True
Dim Arr () As String
Arr=Split (strCheck, ", ")
If UBound (Arr) & gt; 0 Then
'there are multiple data segments
For I=0 To UBound (Arr)
Grammar=GraSection (Arr (I), I + 1)
If Grammar=False Then
The Exit For
End the If
Next
The Else
'only a data segment
Grammar=GraSection (Arr (0), (1)
End the If
End the Function


Private Function GraSection (ByVal strCheck As String, ByVal Index As Long) As Boolean
GraSection=True
Dim Arr () As String
Arr=Split (UCase $(strCheck), "X")
The Select Case UBound (Arr)
Case 0
'indicates that there is an error in the data segment
MsgBox "please confirm that the first" & amp; The Index & amp; "The data if there is no X connector!"
GraSection=False
Case 1
Then If Not IsNumeric (Arr (0))
MsgBox "please confirm that the first" & amp; The Index & amp; "The data of digital section is for digital!"
GraSection=False
End the If
In Case the Else
'indicates that there is an error in the data segment
MsgBox "please confirm that the first" & amp; The Index & amp; Article "is the data with the back of the data connection problem!"
GraSection=False
End the Select
End the Function


CodePudding user response:

refer to the original poster myface2011 response:
last time, in the BBS, I want to separate "1 x bcd_9292" such as the string of number 1 was isolated and string content bcd_9292, special thanks to "sysdzw" last time, help me to solve this problem, my last question, did not consider, there are several ways as follows:
ABC (1) 1 X CVA_8901, 1 X, 2 X CAD;
(2) 1 x cva202
(3) 2 x DEE15043, DEA20201: how is the separation of
(4) 2 x DEE150431 DEA20201 x
This kind of circumstance can you look at, when there is a (3) because one is not match to the quantity, have prompted; (4) in this case, x digital wrote before went to the front, also hope to have prompt,
The regular expression is absolutely powerful, but now I'm in the face of (3) and (4), want to have a prompt, (3) the number of the second sku is artificial reason didn't write; (4) was written, two strings together lead to the number of the second separation not to come out,
Thank you all!
what is your original data? Is what's it like in a variety of data accumulation together? Can copy can also capture,

CodePudding user response:

Summary: data appear mainly has the following format: (1) (2) of the following are about the same, the normal form,
ABC (1) 1 X CVA_8901, 1 X, 2 X CAD;
(2) 1 x cva202
Please see there are several ways:
(3) 2 x DEE15043, DEA20201
(4) 2 xDEE15043 DEA20201
(5) 2 x DEE15043, DEA20201
(6) 2 xdee15043, DEA20201
The (3) (4) (5) (6) the main features are: use a comma between two groups, but the lack of "x" after the comma, I illustrate: basically see in front of a comma, number, between x and the number behind the space problem, all want to consider,
(7) 2 x DEE150431 DEA20201 x
(8) 2 x DEE150431 DEA20201 x
(9) 2 xDEE150431 DEA20201 x
(10) 2 x DEE150431x DEA20201
(11) 2 x DEE150431 xDEA20201
(12) 2 x DEE150431xDEA20201
This group (7) (8) (9) (10) (11) (12) mainly is no commas between the two groups, due to the omission entry, middle forget the commas, and then there is the number of the second group directly behind the serial number of the first group, such as "2 x DEE15043 1 x DEA20201 "actually this 1 is the number of the second group, mainly is the x as the previous number and the number of Spaces behind the problem, this class also prompts to unity, is the problem of data,

CodePudding user response:

Request help me to check it out!

CodePudding user response:

This is the front of the x must have a number of problems,
Read the comma, directly read the second data
No comma read x clue, if the last character in the previous number x prefix Numbers, is divided, and add a comma,

CodePudding user response:

"Compiler principle" reference of lexical analysis and the finite state automata,
  • Related