Regex for getting value from string. This value is different for different records

Regex for getting value from string. This value is different for different records.

60/hr ID 886904
Above is string in this i need to get 60. Please remember this string should be different for different records but /hr will remail same.

Hi @Puneet_Singh1

Try this

\d+(?=/hr)

@Puneet_Singh1

System.Text.RegularExpressions.Regex.Match(Input,"\d+(?=/hr)").Value

or

Input="60/hr ID 886904"
Input.Split("/")(0)

Hope this helps!!

Hi @Puneet_Singh1
Try this:

Input= "60/hr ID 886904"
Output= System.Text.RegularExpressions.Regex.Match(Input,"\d+(?=\/hr)").Value

Hope it helps!!

@Puneet_Singh1

System.Text.RegularExpressions.Regex.Match(Input,“.*(?=/hr)”).Value

image

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