Created
August 12, 2021 17:14
-
-
Save wilsaantos/f2c3ae51ac9df8cfae2ead788e3ad09a to your computer and use it in GitHub Desktop.
Angular CPF Pipe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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