I want remove strings from array specified by index

I have array such as

  1. [001] [10] [F54749] [NW] [Globe Chassis,] [1492] [Model] [28/02/01] [EA] [29.50] [295.00] [Q84645]
  2. [002] [6] [F84352] [NW] [Globe 30"] [Oak] [Stand] [28/02/01] [EA] [30.00] [180.00] [Q84647]

I want remove index number 1,2,3,last,last-1,last-2,last-3,last-4 to extract
[NW] [Globe Chassis,] [1492] [Model] or [NW] [Globe 30"] [Oak] [Stand]

Any suggestion for extraction, if I don’t want to use a regular expression.

StrVal =" [001] [10] [F54749] [NW] [Globe Chassis,] [1492] [Model] [28/02/01] [EA] [29.50] [295.00] [Q84645]"
StrVal = StrVal.Replace("]]"," ").ToString → 001 10 F54749 NW Globe Chassis, 1492 Model 28/02/01 EA 29.50 295.00 Q84645
StrArrVal = Split(StrVal,“NW”)
StrArrVal(0) = “001 10 F54749”
StrArrVal(1) = “Globe Chassis, 1492 Model 28/02/01 EA 29.50 295.00 Q84645”

If i have an array of string like this, I can not use the split method

Current number array is 12

I want to remove 1,2,3,8,9,10,11,12 remain “NW”,“Globe Chassis,”,“1492”,“Model”
Required number array is 4


we dont have any options to remove values in Array based on index. But we can do work aroung like below.

  1. Convert Array to List
  2. Remove the values based on index
  3. then convert List to Array.



Now I can do it.
Thank you for the clear explanation.


Hi @pondyondaime,

Otherwise, if you have the array like this , in your case strArray, you can use like below expression where skip will skip the first 3 items from the array and take method with take 4 items after it skips 3 and store the output in System.collections.generic.ienumerable(of string)


1 Like

Thank you for other alternatives.
Can AsEnumerable method cut last index of array?

In example, I want index number between 4-7, not included after that

@pondyondaime if your index is stable and not making any increment then AsEnumerable function will be useful Other wise you have to read each value from an array index and if it matches with desired string value then use this AsEnumerable function

In my case index not stable because I read string from Read PDF activity

then I split head and footer will get text below
001 10 F54749 NW Globe Chassis, 1492 Model 28/02/01 EA 29.50 295.00 Q84645
002 15 F85352 NW Globe Light Kit 28/02/01 EA 19.00 285.00 Q84646
003 6 F84352 NW Globe 30" Oak Stand 28/02/01 EA 30.00 180.00 Q84647
004 20 L86355 NW Atlas Leather−Bound 28/02/01 EA 25.00 500.00 Q84648
005 12 L86362 NW Atlas Young Readers Series 28/02/01 EA 10.00 120.00 Q84649
006 40 A86357 NW Pen Rollerball 28/02/01 EA 7.50 300.00 Q84650
007 25 A86362 NW Pen Fountain 28/02/01 EA 16.00 400.00 Q84651
008 50 A86552 NW Globe Beach Balls, 24" 28/02/01 EA 5.00 250.00 Q84652
009 100 A84352 NW Promotional Calendars 28/02/01 EA 0.10 10.00 Q84653
010 100 A36352 NW Promotional Balloons 28/02/01 EA 0.15 15.00 Q84654

after that I use for each activity In-argument as Text.Split({Environment.NewLine},stringsplitoptions.RemoveEmptyEntries)

in for each item, item.Split(" ".ToCharArray) so index will not stable

so I think array to list and use RemoveAt probably the easiest way.

This has to design in a different way. once you read PDF data into a String.
Just split based on VBNewLine.
That will give each line into each Array value. also use UBound function to get maximum number of lines to make iteration (take do while loop) till end of the page.

Where as ReadCount = 0

1 Like

Thank you for sharing ideas.
This way is easy to understand. I will apply in my work. :grin:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.