How to write regex for the following text

can anyone send me regex pattern for the following text

2869-1-456789 My_sheet_34567_Doc
2345-1-456782 My_Job_45789-copy

here i want the text from second hyphen

output should be only 456789
456782

Hi @T_Y_Raju ,

(?<=(?:[^-\n]+-){3}).*(?=\sMy)

image

Try this

Regards,
Vinit Mhatre

HI,

How about the following expression?

System.Text.RegularExpressions.Regex.Match(yourString,"(?<=^\d+-\d+-)\d+").Value

Regards,

Hi @T_Y_Raju

\d{3,}(?=\s)

\d{3,}(?=\s[A-Za-z]+)

Hope it helps!!

If that is a standard format, I will not even use regex to extract that output. String manipulation will do.
First use split to split the input using the space as the splitter:
e.g.
strOutput = strInputSring.Split(" "c)(0).toString

Then use substring to get final output

strOutput = strOutput.Substring(strOutput.Length - 6,6)

Hi @T_Y_Raju

Try this:
(?<=-)\d+(?= [A-Za-z])
image

Hi @T_Y_Raju

Try this:

System.Text.RegualarExpressions.Regex.Match(Input,"(?<=\d+\-\d+\-?)\d+").Value.Trim

Hope it helps!!

where should i write System.Text.RegualarExpressions.Regex.Match(Input,“(?<=\d+-\d+-?)\d+”).Value.Trim

in Assign statement

Hi @T_Y_Raju

Use it in Assign activity.

Save To: Output
Value to Save: System.Text.RegualarExpressions.Regex.Match(Input,"(?<=\d+\-\d+\-?)\d+").Value.Trim()

Output is of DataType System.String
Regards

@T_Y_Raju

Use assign activity

To:Str_Output

Value:System.Text.RegularExpressions.Regex.Match(Input,“(?<=-)\d{5,}”).Value
image

@T_Y_Raju

Give the regex in the Pattern
Give the text in Text to be seached in

Hi @T_Y_Raju

Or you can try this way:

Input = "2869-1-456789 My_sheet_34567_Doc
2345-1-456782 My_Job_45789-copy"

→ Find matching Patterns:

Pattern: "(?<=\d+\-\d+\-?)\d+"


→ Use the below syntax in Assign

Output = String.Join(Environment.NewLine, Output.Cast(Of Match)().Select(Function(m) m.Value.Trim()))

Output variable will print all the matches.

Hope it helps!!

@T_Y_Raju

if the format is standard you can directly use split

requiredvalue = str.Trim.Split({"-"," "},StringSplitOptions.None)(2)

cheers