Regular expression in data extraction

Hi all,

In data extraction if any sentence starts with “x” or “X” only that particular line should pick, but here its picking only " as necessary" its mentioned in below image

image
Please help me on this.

Regards,
Lakshmi

HI @lakshmi.mp

Share the sample input and expected output

Regards
gokul

Hi @Gokul001 ,
Input:
Read, invoke, and repair Gbox as necessary.
x Read, invoke, and full furbish Gbox as necessary.
Expected output:
Read, invoke, and full furbish Gbox as necessary.

Thanks,
Lakshmi

Hi @lakshmi.mp

Try it out

System.Text.RegularExpressions.Regex.Match(YourString,"^x.*|^X.*").Tostring

1 Like

Check out the above regex @lakshmi.mp

image

Need to remove x from above text.
Read, invoke, and full furbish Gbox as necessary.

image

System.Text.RegularExpressions.Regex.Match(YourString,"(?<=^x).*|(?<=^X).*").Tostring

Hope it will works

Regards
Gokul

image

System.Text.RegularExpressions.Regex.Match(YourString,"(?<=^x|^X).*").Tostring

Regards
Gokul

1 Like

Hi,

How about the following expression?

System.Text.RegularExpressions.Regex.Match(yourString,"(?<=(^|\.)\s*[xX]\s*)[^.]+(\.+|$)").Value

Regards,

1 Like

Hi @Yoichi , @Gokul001 ,

Both the expression are working fine, thank you.

Regards,
Lakshmi

1 Like

Kindly close this topic by mark as solved. It will help for other user too @lakshmi.mp

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