Skip to content

Instantly share code, notes, and snippets.

@xx4159
Last active July 3, 2019 03:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xx4159/d5d3ffb341caaeb87af2358259e93f50 to your computer and use it in GitHub Desktop.
Save xx4159/d5d3ffb341caaeb87af2358259e93f50 to your computer and use it in GitHub Desktop.
Replace curly braces to span
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'replaceCurly'
})
export class ReplaceCurlyPipe implements PipeTransform {
transform(value: string): string {
const regex = /\{\{([^\{].*?)\}\}/g;
if (value) {
return value.replace(regex, `<span>$1</span>`);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment