src/app/pipes/string/replace/replace.pipe.ts
Replace pipe
name | replace |
transform |
transform(input: any, pattern: any, replacement: any)
|
Returns :
any
|
import { Pipe, PipeTransform } from '@angular/core';
import { isString } from 'util';
/**
* Replace pipe
* @author Daniel Sogl
*/
@Pipe({
name: 'replace'
})
export class ReplacePipe implements PipeTransform {
transform(input: any, pattern: any, replacement: any): any {
if (!isString(input) || !pattern || !replacement) {
return input;
}
return input.replace(pattern, replacement);
}
}