Take out numeric from string

Hi Guys,

100/200/20/11982 (19 items)

I want to take out numeric value between braces from the above mentioned string.

Please guide me on this.

Thanks in advance

@Rahul_Jawahirani - Please try this pattern…

Output = Regexvar(0).groups(1).tostring

Hope this helps…

@Rahul_Jawahirani

Another way would be

System.Text.RegularExpressions.Regex.Match(varStr,"(?<=[(])(\d|.){1,4}").Value

It worked…

Thanks @Pravin_Patil1

Hi,
you can try:

output = System.Text.RegularExpressions.Regex.Match(your_String, "(?<=\()\d{1,}").Value

output = String
your_String= String

image

Or:

output = System.Text.RegularExpressions.Regex.Match(your_String, "(?<=\()\d{1,}(?=\s+items\))").Value

output = String
your_String= String

1 Like

It worked…

Thanks alot@Adrian_Star

1 Like

CInt(“100/200/20/11982 (19 items)”.Split(“(”)(1).Split(" ")(0))

Splits on the ( and takes the second part of the split then splits again on the space and takes what’s before the space. Converts the resulting value to integer.

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