String Operatons

HI @ All,

I have a scenario like in excel I have a data
Example - TSPRST12378QR-QT

Here I need to remove from right side first R,with including that R I need to remov
output - TSPRST12378Q
I need output like this,can you suggest me

@varunk In assign activity use like this urvariable = urvariable.Substring(0,12)

Hi @indra,

But for few rows of data it will be like less than 12,then it will throw error

@varunk Can you share some sample strings

data

Please find the sample

@varunk

You can try using REGEX

   output_string = System.Text.RegularExpressions.Regex.Match("TSPRST12378QR-QT","(\w+)(?=R.*)").ToString

Hi @ranjith,

Same case we need to check with R & T
if it ends with R rest of we remove & it ends with T rest we need to remove
from right hand side we need to check if it is ending with T & R

@varunk

Can you share input and output sample for the T case.

data

In this above image both ends with T & ends with R we have
If from right hand side starting With T then it will remove data from T
If from right hand side starting With R then it will remove data from R

This solves for the first case you asked for
Input.Substring(0,Input.Length-((New String( Input.ToCharArray.Reverse().ToArray)).IndexOf(“R”)+1))

Can you send us a sample showing Input and Output of some of the data to clearly understand.

io%20pic

Please find the image for better understanding of scenario

Hope this solves.
Main.xaml (7.1 KB)

Hi @Karthick_Settu,

Am getting this error in your flow
Please check this errorerr

Check this
Main.xaml (7.7 KB)

1 Like

@varunk Try this

output_string = System.Text.RegularExpressions.Regex.Match("TSPRST12378QR-QT","(\w+)(?=(R|T).*)").ToString

4 Likes

Hi @ranjith

I need to do for another thing in that
from right if first we have R we need to take left three digits from R
from right if first we have T we need to take left three digits from T
Please find the input & outputerr2

@varunk

(\w{3})(?=T|R) Try this pattern

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