Need to split the string into two sub strings based on special characters(there is no particular length)

I have data like this
1938-13545 - Wofsy - RM
256560 / 13933
Expert Witness ck beck an
28400/4692
Here i need to extract Digits only but i want like this 1938,13545 separately and remove other characters(in place of - we may also get any special characters based on that character i want to separate the data)

Output:
1938
13545
256560
13933
Empty
28400
4692

1 Like

Looking at your pattern, btw what will be your input? you can apply a for each loop on your content and string contains / then split according to it or else split by - this will give you array you can then access array items by indexes like array(0), array(1) and so on

input :1938-13545 - Wofsy - RM
output : 1938
13545
input : Expert Witness ck beck an
output :
input : 256560 / 13933
output : 256560
13933

Each time i’m taking 1 string. If string contains only text then output is empty or it contains 1938-13545 - Wofsy - RM then the output is 1938 and 13545 separately. Thanks @PrankurJoshi

1 Like

See this -

Main.xaml (9.2 KB)

This is very basic example you would have to optimize by string operations or matches it according to requirement. Let me know if this works. And if you want only number not text

2 Likes

@sindhura506 Please find attached workflow.

new1.xaml (5.9 KB)

3 Likes

Hello,

is your text contained in a file or in memory (ie variable) ?

input is from excel. 1 column contains these strings. Thank you @mustafa.altinbasak

My exact requirement is i need to print the text before special character and after special character up to space.if the string doesn’t contains any number we need to print empty.

Ex: i/p - 45454 @ 9898fgf kdmkjkjh dfdkjkl
o/p - 45454 and 9898fgf

1 Like

Then I guess you can use what @adarshk has suggested if you want other data as well from the string you will have to perform more string operation like I mentioned

2 Likes

Thanks @adarshk … It is working…can i store output in two different variables?

Shouldn’t it be as easy as creating 2 variables, and assigning them ā€œitem.ToStringā€ as value ? :yum:

1 Like

@sindhura506 we should convert ienumerable to list or array, and then output the element in those to variables based on index.

1 Like

Try using regex options to extract only numbers rather than trying substring as the length is not fixed.ā€œ/dā€ in regex should be able to give you all the digits present in the complete string

good evening.

i have tried to get the specific number from a string which is stored in a variable.
for an example
stringtext(variable) = my 1st professional id is 7654367 for the company

from the above example i need to extract only that 7 digit number.

i have tried System.Text.RegularExpressions.Regex.Replace(demotest,ā€œ\Dā€,ā€œā€)

but it returns the result including the number 1 from the second word of the string.

can anyone help me out with this. please.

Hi @sathwikreddy

You were almost there, here’s a correction to your regex. Instead of removing the other non-digits in a string, you can directly select the first match of 7 consecutive digits, like this:

System.Text.RegularExpressions.Regex.Match(demotest,"\d{7}").ToString
2 Likes

thanks for the solution. it helped a lot.

I want to extract a match of 10 digits using this method, though I can not assign that expression to my variable, I type ā€˜.’ after my variable in the value section of the assign activity, nothing like this shows up. I tried to look for a package that contains that code but I do not make it to install System.Text.RegularExpressions.Regex class, Package installation failure shows in red in the packages section.

Thanks!