Skip to content

Instantly share code, notes, and snippets.

@sangress
Created December 27, 2016 16:22
Show Gist options
  • Save sangress/edf38e7e574e10e89c8e90821178a0df to your computer and use it in GitHub Desktop.
Save sangress/edf38e7e574e10e89c8e90821178a0df to your computer and use it in GitHub Desktop.
Angular2 replace pipe
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'replace'
})
export class ReplacePipe implements PipeTransform {
transform(value: string, expr: any, arg2: string): any {
if (!value)
return value;
return value.replace(new RegExp(expr, 'gi'), arg2);
}
}
@jchome
Copy link

jchome commented Mar 31, 2021

Hello ! Thanks to share this tip. Can you explain how to use it (in a comment block)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment