How to extract a string from a given string?

Hi All

I have a string “KP-2-UM-1”.

I want to get “2-U-1”. How can I do that using regular expression ?

Can I do that using Assign activity ?

@kkpatel
Try this :
System.Text.RegularExpressions.Regex.Match(Test_String1,"(?<=KP-)[\d-]+[\w]+-[\d]+").ToString.Replace(“M”,"").ToString

Hi,

Can you share rule to extract it?

Regards,

Its giving blank.

@kkpatel

try This -

System.Text.RegularExpressions.Regex.Match(Test_String1,"(?<=KP-)[\d\-]+[\w]+\-[\d]+").ToString.Replace("M","").ToString
1 Like

Hi @kkpatel

What’s the rule for extracting ?

Hi!

Try this!

System.Text.RegularExpressions.Regex.Match("StringInput","\d.[a-zA-Z]{1,}.\d").ToString

Reference:

Regards,