Get Specific text from String

Dear Forum members,

I have one String str= Hello | ID 345.

I want only 345 not other text.

Can anyone help me regarding this.

Regards,
Sahil

Hi,

Can you try the following expression?

System.Text.RegularExpressions.Regex.Match(str,"\d+").Value

REgards,

2 Likes

Hey Mate,

Your expression is helping only to extract integer value.

In the string i want to remove Hello | ID , after that there can be anything , i want after that text only.

Thanks,
Sahil

Hi,

How about the following?

System.Text.RegularExpressions.Regex.Match(str,"(?<=Hello \| ID ).*").Value

REgards,

Mate,

Please see this string “PO Closure | PO Number MGAG342”

I want after PO Closure | PO Number.

Your expression is not helping in this specific case, Hello | ID i gave for example only.

I want to remove above specific str.

@Sahil_Garg1,

Can you give us a list of full example strings, and for all the data you want to keep make it bold?

Hey,

Please see this str. This is specific requirement.

Hi mate,

Please help me regarding this specific expression .

@Sahil_Garg1,

If the string’s format is consistent and the data you want is always on the end of the string, you could do the following in two assigns:

StringArrayVar = StringVar.Split({" "},StringSplitOptions.None)
StringVar = StringArrayVar((StringArrayVar.Count)-1)

This will split the string by space (" ") and then take the last item in the array

1 Like

Thanx mate, your idea is working.

1 Like

Thanx for your help also buddy.

1 Like

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