Skip to content

Instantly share code, notes, and snippets.

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