Extract a number from string

i have string → 00000000000000000000000000000000000000000013584500000000000000000N0000000000135845

i wants to extract on 135845 from this string
every time the number changes it my be 5 digit or 8 or anything
like this → 0000000000000000000000000000000000000001800000000000000000N0000000000000018 from this string i want 18

HI @pravin_bindage

Try this expression

System.Text.RegularExpressions.Regex.Match(YourString,"[1-9]+$").Tostring.Trim


Regards
Sudharsan

1 Like

Hey @pravin_bindage

Take a look at this updated pattern:

image

Cheers

Steve

1 Like

Hi

It’s as simple as this

Use a expression like this

str_output = str_input.ToString.TrimStart(“0”c).ToString

Where str_output is of type string variable

to remove zero after no use
text = your_Variable

use this text.Remove(text.Length-1)

Cheers

Can you share the data that is in the file variable? @pravin_bindage

Sorry brother that solution is working thanks

1 Like

But if in some cases no like this 107856 then what can i do?

@Sudharsan_Ka @anon87560229 in some cases number like this 1073569 then what can we do?

Check with this expression @pravin_bindage

System.Text.RegularExpressions.Regex.Match(YourString,"(?<=0)[1-9]+\d+$").Tostring.Trim


again same problem null result

Hi,

Can you try the following?

Decimal.Parse(System.Text.RegularExpressions.Regex.Match(yourString,"\d+$").Value).ToString

Regards,

Can you show the expression you written? @pravin_bindage

System.Text.RegularExpressions.Regex.Match(Text1,“(?<=0)[1-9]+\d+$”).Tostring.Trim


input string format problem

format is string

Hi,

There might be extra white space at the end of the string.
Can you try to use Trim method as the following?

Decimal.Parse(System.Text.RegularExpressions.Regex.Match(yourString.Trim,"\d+$").Value).ToString

Regards,

yes now its working

1 Like

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