How can I extract and store a part of the string and store it in a table?

advertisements

I have a file array which carries strings in the following format:

"abc12345.xxx_xxx001.001045"

The string stored in above format helps me do a portion of my job

Now, having stored this, I want to extract a portion of this string and store it an array

How do I extract "abc12345" alone from this string and store it an array?

I tried using the split command. The problem am facing is:
PN(0) stores abc12345
PN(1) stores xxx_xx001
PN(2) stores 001045
I want abc12345 to be stored as PN(0) and next subsequent part number to be stored as PN(1)

Copy Code

Dim PN As New ArrayList()
For Each element In file1array
    PN = element.split("."c)
Next


Assuming that every element contains a period and the first segment is the part number,

pn = file1Array.Select(
    function(element as string)
        return element.Split("."c)(0)
    end function
    ).ToArray()

This would return pn as an array of string, not an ArrayList.

It's saying, for each element in file1Array, split element into an array and return the first element in that array (the part number.)

Then take all of those values and put them in an array.