Today, I want to develop a batch Comparison Program for extracting ID cards. I wrote a basic algorithm, but I have not yet verified how to extract ID card numbers (the last character of ID card can be a character)
Extract numeric strings only
The algorithm for serial number extraction in the text box:
1. determine the sequence stream of the text box, such as label_stram.text.
2. Determine a list box to separate the extracted numeric strings, such as ListBox
3. Identify and obtain numeric strings by counter and add them to the ListBox element one by one
/// <Summary>
/// Extract a numeric string from the string
/// </Summary>
/// <Param name = "str"> </param>
/// <Returns> </returns>
Public void storenumstr (string Str)
{
// Start indexing with numeric characters
Int I _start =-1;
// Numeric character final index
Int I _end =-1;
// Counter
Int COUNT = 0;
While (count <= Str. length)
{
If (I _start =-1)
{
// When the start index does not exist, the number is immediately recorded to start the index.
If (char. isnumber (STR, count) = true)
{
I _start = count;
// Count increases after detection
Count = count + 1;
}
Else
{
// Count and Add 1 If no result is found
Count = count + 1;
}
}
Else
{
// When the index starts to exist, it determines that the character currently being read is a number.
If (char. isnumber (STR, count) = true)
{
I _end = count;
Count = count + 1; // enter the next Analysis
}
Else
{
// When the index starts to exist, it determines that the character currently being read is not a number;
I _end = count-1;
// Truncate a numeric string
ListBox. item. Add (Str. substring (I _start, I _end-i_start + 1 );
// Clear the start index;
I _start =-1;
I _end = 1;
// Count continues to increase
Count = count + 1;
}
}
} // End while)
} // This method ends