-3
Guys, I need to pull from a string, by Regex, all content that is not equal to CNPJ.
Ex:
Flap1 -> 123 - EMPRESA CICLANO101 30.589.587/0001-87
Line2 -> 4567 - FULANO LTDA28.819.917/0001-31
Line3 -> 90 - ComPANHIA DEDE 77.282.198/0001-78
Cnpjs always stay at the end of the string, and the above examples happen. I’m using "Replace in String", from Pentaho.
The regex of the CNPJ would be:
\d{2}\.\d{3}\.\d{3}\/0001-\d{2}
– Sam
@Sam I think I’d better use
\d{4}
instead of "0001". All right, the vast majority of Cnpjs have 0001, but that’s not always the case. That number corresponds to the subsidiary, so a company with several subsidiaries could have 0002, 0003, etc. I have seen up to 0010, for example (the tenth subsidiary of the company)– hkotsubo
Luiz, regex will only validate if there are the correct characters in the desired position and quantity, eg: digits, dot, hyphen, etc. But I would also validate the check digits out of from regex, just to make sure the CNPJ is valid (this is useful to avoid typos, for example)
– hkotsubo
@hkotsubo has a point.
– Sam