Simple regex for 5/5

Hello,
I am new to Regex.
I need a regex to get the below value.
5/5 … : I need first digit, Var1 = 5
10/10 … : I need first digit, Var1 = 10
23/23 … : I need first digit, Var1 = 23

Thanks

Hi @Gagan_Chaudhari

How about this expression?

System.Text.RegularExpression.Regex.Match(InputStr,"^\d+").Tostring

Regards
Gokul

Hi @Gagan_Chaudhari

Can you try this

Split(str_input,”/”)(0).ToString.Trim

If regex

^\d+

Thanks

find an anchored regex pattern, defensive to some variations
grafik

\d+(?=.*?\/)

Thanks a lot for this
Apologies I just got the update and now my input string values are like this:

Record: 5 /5 … : I need first digit, Var1 = 5
Record: 10 /10 … : I need first digit, Var1 = 10
Record: 23 /23 … : I need first digit, Var1 = 23

Using ur regex getting below output
Record: 5
Record: 10

image
@Gagan_Chaudhari
try this
Record:\s\d+(?=.*?/)

Hi @Gagan_Chaudhari

How about this expression?

System.Text.RegularExpression.Regex.Match(InputStr,"(?<=Record:\s)\d+").Tostring

Regards
Gokul

Getting this error
variable type is String

Try with is expression

RegularExpressions is missing

System.Text.RegularExpressions.Regex.Match(InputStr,"(?<=Record:\s)\d+").Tostring

Regards
Gokul

a tolerate one
grafik

Record.*?(\d+)(?=.*?\/)

for further cleansing the number we can get from group 1
grafik

@Gagan_Chaudhari Try to import name spaces from imports panel

  • Navigate to Imports Panel
  • Search for System.Text.RegularExpressions and import it and see it is that error still appears