String manipulate

Hi,
Here is my string like
12545 25898
1 Customer
1 Manager

but sometime there is case where 12545 25898-HR
1 Customer
1 Manager

from above string i want to only 25898 and 25898-HR
then how i do

1 Like

Hi @Rup_1,

You can use the String manipulation method (Split Method) to get the appropriate result.
Here, you just have to split the given string by whitespace using: str.split(" "c)
and assign this to a variable type “array” & get the resulted string by arr[1].toString.

(Given that, your string be “12545 25898-HR 1 Customer 1 Manager”.
If the given string is in different lines, then you can first split them by: str.split(Environment.Newline) and then split by whitespace as mentioned above)

Hope this helps :slight_smile:

1 Like

12545 25898-HR
1 Customer
1 Manage

Does you string have new lines(above) or is it just one liner(below)?

12545 25898-HR 1 Customer 1 Manage

Hi,

from item section i have to fetch 5041-24HR but sometime its “25485” and from item section i want to read only number

Hi,
When we use split function it will be fine for 12545 but not for 25898-HR

Hi Rup,

It should be fine for both because we are splitting based on space and 25898-HR this will be a single string.

Sorry @Rup_1 just confused.

Actually if you want the item number regardless of 5041-24HR or 25485 you will get it using string manipulations

Do you only want the number part 5041-24HR?

Hi,
Suppose this is string:-
12458 25878
now i want to fetch 25878 but sometimes the string is:-
12458 25878-HR
in this situation i want to fetch 25878-HR

Hi,


like this is string and i want to fetch only number from item# sometime is 13424 or it may be 13255-HR

Hi,
it will be work with the help of splitting by space but then problem occur on “Set-up charge” so i want to fetch only number from item#

It should not.
When you will split 12545 25898-HR 1 Customer 1 Manage using " " [space]
you will get an array {12545, 25898-HR,1,Customer,1,Manage}
So when you do array(1) you will always get the value which will be in the second position. Be it 25898 or 25898-HR

1 Like

Hi,
you are correct if i split by space then i got ouput on array(1) but then i got “set-Up” (you can check on above image) so that i don’t want.i want only number

Ok, lets take a step back.

can you tell me how you are getting this data out from this invoice into your workflow?
Scraping?

Hi,
by using c# code i fetch the data from invoice and when i execute i get output like this.

297 13424 h2go bfree Fusion Sport Bottle - 23 oz. 2.7750 824.18
0 - (Base, Trim) : Translucent Graphite , Stainless
Steel
1 Set-Up Charge Set-Up Charge 44.0000 44.00
1 *Prepro Proof Charge Prepro Proof per Color 24.0000 24.00

i am able to fetch those record which are highlighted now i want to fetch item# and description(Header are in above image)

  • from Item# i want only number

If you want to check if array(1) is starts with a number then you can use regex to identify it.
It will ignore if Set-Up and take 1234 or 1234HR

Hi
could you please suggest which regex should i use.
I am using “”\d{4,}" it identify number but for string like (“Setup charge”) it takes 0000 i.e for every string it takes 0000 that should be avoided.

The regex is fine. What you can do is add a IF check after and if the string is like 0000 you leave it
Then you move to the next one .
Im sure you are using a loop to iterate through your extracted data

1 Like