Extract part of specific text line

I have the following text stored in the varTxt variable and I need to extract the CPF number “01_Proponente_CPF03625419858_Joao Paulo da Silva”, how can I do it?

grafik

we can do it with regex:
(?<=CPF)\d+

Regex.Match(YourStringVar,"(?<=CPF)\d+").toString

ensure following:
grafik

Also have a look here:

2 Likes

You can use regular expression to extract it as @ppr proposed. But to be able to generate a safe regular expression we will need more examples. For example, does it always start with “CPF” followed by 11 digits? Do you only want the number part or do you want to extract the CPF part too? “03625419858” or “CPF03625419858”?

2 Likes

@ppr, It worked perfectly, thanks for the quick help.

Thank you @ptrobot , the answer above meets what I need.

1 Like

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