Can anyone please Help me to solve this regex

~AA230% -~104,561.91
~FINALSUM

~DATA#

This is the input i want to extract FINALSUM as the output.“~AA230% -~104,561.91” it can vary.it wont be same in next case.
Can anyone please help me to solve this issue.

FINALSUM, is the static keyword ?

HI @Chippy_Kolot

Can you share the Output

Try with the below regex expression

System.Text.RegularExpressions.Regex.Match(YourString,"\d+[,.].*").Tostring

image

Try with the below regex expression

System.Text.RegularExpressions.Regex.Match(YourString,"(?s)~(\S+\d.*%)").Groups(1)

image

Regards
Gokul

Try this, If -FINALSUM is word in TexT
(?<=~).*(?=\n~FINALSUM)

System.Text.RegularExpressions.Regex.Match(YourString,"(?<=~).*(?=\n~FINALSUM)").Tostring.Trim

Also try this
(?<=~).*(?=~FINALSUM)|(?<=~).*(?=\n~FINALSUM)
image

I want to extract “FINALSUM”, this is the output

is the static one @Chippy_Kolot

Hi @Chippy_Kolot ,
try this:
System.Text.RegularExpressions.Regex.Match(YourString,“FINALSUM”).Tostring

Thanks & Regards,
Shubham Dutta

It is not static

This is the Output @Chippy_Kolot

@Chippy_Kolot
Kindly provide 2 different inputs and indicate the expected output.It help us to provide you better solutions

HI @Chippy_Kolot

How about this expression

System.Text.RegularExpressions.Regex.Match(YourString,"(?<=~)(\S+\d.*%)\s-~(\d.+)").Groups(1)
System.Text.RegularExpressions.Regex.Match(YourString,"(?<=~)(\S+\d.*%)\s-~(\d.+)").Groups(2)
System.Text.RegularExpressions.Regex.Match(YourString,"(?<=\d\n~)\S+").ToString

image

image

Regards
Gokul

HI @Chippy_Kolot

You can try with these regex expressions

System.Text.RegularExpressions.Regex.Match("Your string variable","(?<=\d\n~).*").ToString

or try this

System.Text.RegularExpressions.Regex.Match("Your string variable","\S+(?=\n{2}~DATA)").ToString.Replace("~","")

Regards
Sudharsan

Hi @Chippy_Kolot ,
try this:
System.Text.RegularExpressions.Regex.Match(YourString,“(?<=\d\n~)\S{1,}”).Tostring

image

Thanks & Regards,
Shubham Dutta

Have you tried the above expression @Chippy_Kolot , Did you received correct output?

Let us know do you having any queries

Regards
Gokul

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