Skip to content

Instantly share code, notes, and snippets.

@wilsaantos
Created August 12, 2021 17:15
Show Gist options
  • Save wilsaantos/8598cd4e0d8907d241464923226bb293 to your computer and use it in GitHub Desktop.
Save wilsaantos/8598cd4e0d8907d241464923226bb293 to your computer and use it in GitHub Desktop.
Angular CNPJ Pipe
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({ name: 'CNPJ' })
export class CNPJPipe implements PipeTransform {
transform(value) {
return value.replace(/(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})/g, "\$1.\$2.\$3\/\$4\-\$5")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment