Hi can anyone please help me solve regex issue

~AA40% -~13,683.89
~FINALDATA

~PA RT#
This is the input from here i only want to extract FINALDATA as output, but im facing space issue between ~PA RT# and FINALDATA
I provided regex in matches as \S.+\n(?=(~PA RT#)),I have similar txt files,but all are reading FINALDATA in those txt files space is not there between FINALDATA nad ~PA RT#. Can anyone please help me to resolve this

Hello @Chippy_Kolot ,

You can do as per the below screenshot.

\S.+\n(?=(~PA RT#))|\S.+\n\n(?=(~PA RT#))

image

Thanks,
Sanjit

[A-Za-z ](FINALDATA)[A-Za-z ]

You can do something like this if your text is the same.

image

Hello

Take a look here.

Preview the pattern here.

Pattern:
[A-z\s]+(?=[\r\n]+~PA\s+RT)

Cheers

Steve

Hi @Chippy_Kolot

You can try with Regex expression

System.Text.RegularExpressions.Regex.Match(YourString,"(?<=\d\n~)(\S+)(\n\n~)(\S.+)")Groups(1)

Output : FINALSUM & FINALDATA
System.Text.RegularExpressions.Regex.Match(YourString,"(?<=\d\n~)(\S+)(\n\n~)(\S.+)")Groups(3)

Output : DATA# & PA RT#

Hello @Chippy_Kolot
Kindly try this
(?<=~).*(?=\n\n~PA)

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

image

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.