Specific String Extraction

Team, Need to extract required string where Input can be vary but desired output is required.

Input1 = Showing 1-20 of 21 results
Output = 21

Input2 = Showing 1-20 of 10983 results
Output = 10983

Note It should be case sensitive (ie both capital and small alphabets should work).

Thanks in advance

You can use string.split(" "c) and then get the number based on its index

or use regex

Regards

Index is not constant

@prerna.gupta
Screenshot (83)

Regards

grafik

strtext = Your Text
strPattern = "(?<=\d+ of )\d+"

strValue = System.Text.RegularExpressions.Regex.Match(strText, strPattern).Value

Hi @prerna.gupta

You can try with Regex expression

System.Text.RegularExpressions.Regex.Match(YourString,"\d+(?=\sresults)").Tostring

image

Regards
Gokul

1 Like

If we need to further verify strValue > 10K then do we need data type changes ? As string wont support double data type

focus on this topic scoped to 1 Topic = 1 case on extraction.

For need on conversion just open a new topic and share with us all samples, that you are expecting. Thanks

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