How to get specified string from a sentence

Hi All,

I Have a string “28082021 SET68181210828713759 SPM DEP”
From above I just need “SET68181210828713759” and some time it will come as “Set68181210828713759”.(we must ignore the case)

Someone please help to do the same.

Hi @HeartCatcher

Please try this,

inputstring - your text

System.Text.RegularExpressions.Regex.Match(inputstring,"Set\d+",regexoptions.ignorecase).tostring

Thanks

1 Like

@HeartCatcher
If the string position remain same, u can try split string method as well using regex

System.Text.RegularExpressions.Regex.Split(data,"\s+")(1).ToString

where data = “28082021 SET68181210828713759 SPM DEP”

Regards,
Nived N

2 Likes

Hi

Let’s do it with a simple SPLIT Method

If your string is in a string variable named str_input

Then use this expression in a assign activity

str_output = Split(str_input.ToString,” “)(1).ToString.Trim

Here we are trying to spit with space between each words
And (1) represent the second word here in this sentence

So any word that comes there may be upper or lower case it will be picked

Cheers @HeartCatcher

2 Likes

@Palaniyappan ,
But there are many data like
“28082021 SET68181210828713759 SPM DEP”
“28082021 Set76854480981234567 SPM DEP”
in a excel column it could around 1 records or many records(minimum 100 records)

No worries if these value are in each row one after the another then you can pass the datatable to a FOR EACH ROW activity and inside that loop use this assign activity like this

Str_output = Split(row(“yourcolumnname”).ToString.Trim,” “)(1).ToString.Trim

If all of them are in one cell like if this is a single value with multiple lines it
Then the activity used will be

—use a assign activity like this
Arr_line = Split(str_input.ToString,Environment.Newline.ToArray())

Where arr_line is a array of string type

Now use a FOR EACH activity and pass the above array variable as input and change the type argument as string

Inside the loop use a assign activity like this

Str_output = Split(item.ToString.Trim,” “)(1).ToString.Trim

Cheers @HeartCatcher

3 Likes

Hi @Palaniyappan,

Thanks a lot man, you and many people saving me from this kind of stuffs its meant a lot.

2 Likes

Anytime @HeartCatcher
Have a great day

1 Like

@NIVED_NAMBIAR ,
Thanks very much.

1 Like

@prasath_S ,

Thanks very much

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