Extract specific numbers from a string

I have a text which is like
Forms: 45 (10 shown)

I only need 10 from the above text…how can I extract that…
the number inside the “(” can be single digit or multiple digits

Hi @Jalan_Pranav

How about this expression?

Use assign activity

Str1 = Split("Forms: 45 (10 shown)","(")(1)

image

Use Assign Activity

System.text.RegularExpression.Regex.Match(Str1,"\d+").Tostring

Regards
Gokul

3 Likes

Hello @Jalan_Pranav
Try this

Input=Forms: 45 (10 shown)

Split((Split(Input, “(”)(1).tostring)," ")(0).ToString

image

1 Like

Hey! Welcome back to Community…

We can do like this

System.Text.RegularExpressions.Regex.Match(strInput,"(?<= \d.\s.)\d+(?= shown)").ToString

Reference:

Regards,
NaNi

find two regex pattern:
grafik
second one is a more tolerant on any chars between ( and the first found digit block

System.Text.RegularExpressions.Regex.Match("Forms: 45 (10 shown)","(?<=\()\d+").Value
 "10"
 System.Text.RegularExpressions.Regex.Match("Forms: 45 (   10 shown)","(?<=\(.*?)\d+").Value
 "10"

Thanks…this worked

System.Text.RegularExpressions.Regex.Match(“Forms: 45 (10 shown)”,“(([0-9]+).*)”).Groups(1).Value
“10”

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