Extracting text from a specific character onwards

As per title, I’m trying to extra information from a specific character (in this case, the 3rd dash)

strOriginalVariable: dwedwe-d-dsdsd-434ff-tyrt34
strOutputVariable: 434ff-tyrt34

I’ve tried strOutputVariable.Substring(strOriginalVariable.LastIndexOf(“-”) + 1)

this outputs ‘tyrt34’

So I amended it to this:
strOutputVariable = String.Join(“-”, strOriginalVariable.Split("-"c).Skip(3).ToArray())

But it produces the error: 'Cannot assign from type ‘system.boolean’ to ‘type ‘system.string’ in assign activity ‘Assign’’

Any help would be much appreciated.

Hi @steve1977beyond

String.Join("-", strOriginalVariable.Split("-"c).Skip(3).ToArray())

Hi @steve1977beyond

Try below

String.Join("-", Input.Split("-"c).Skip(3).ToArray())

Cheers!!

Hi,

How about the following regex?

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

Regards,

grafik

Hi @steve1977beyond

Try the below syntax:

Assign -> strOriginalVariable = "dwedwe-d-dsdsd-434ff-tyrt34"
Assign -> strOutputVariable = String.Join("-", strOriginalVariable.Split("-"c).Skip(3).ToArray())
Message Box -> strOutputVariable

Note: strOriginalVariable, strOutputVariable are of DataType System.String

Regards

cheers everyone, I managed to find a solution also with the following

strOutputVariable = strOriginalVariable.Substring(strOriginalVariable.IndexOf(“-”, strOriginalVariable.IndexOf(“-”, strOriginalVariable.IndexOf(“-”) + 1) + 1) + 1)

Hi @steve1977beyond

You can use the regular expressions to extract the required input.

- Assign -> Input = "dwedwe-d-dsdsd-434ff-tyrt34"
- Assign -> Output = System.Text.RegularExpressions.Regex.Match(Input.ToString,"(?<=[\s\S]+\-[\s\S]+\-[\s\S]+\-)[\s\S]+").Value

Check the below image for better understanding,

image

Hope it helps!!

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