Take middle word from the string

I am having Queue reference like below
12345_Facebook_Prod
12345_Linkedin_UAT
12345_Twitter_SIT

From the above queue reference, How should i get the middle words(Facebook, Linkedin, Twitter).

Thanks in advance.

Hi,

How about either of the following?

yourString.Split({"_"c})(1)

Or

System.Text.RegularExpressions.Regex.Match(yourString,"(?<=_)[^_]+").Value

Regards,

Hi @ManjunathReddy

You can use regex as below

(?<=\d+_)\w+(?=_\w+)

or

you can also use string manipulation by splitting with “_”

Hope it helps!!

@ManjunathReddy

Assign Activity:
InputString = “12345_Facebook_Prod”
Pattern = “\d+(\w+)\w+”
Matches = System.Text.RegularExpressions.Regex.Match(InputString, Pattern).Groups(“1”).Value

@ManjunathReddy
Assign Activity:

  • Use the Assign activity to extract the middle words. You can use the Split function to split the queue references based on the underscore character and then select the middle element.
    Assign: middleWords = queueReference.Split("_"c)(1)

image
Try with this regex

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