Ask away

Javascript component replacing text in string with other text

Tony 10/10/17 17:41

10 views

Question CategoryComponent,Properties

Number of completed projects0

Question StatusUnsolved

  • javascript
  • component
  • text
  • string

Question

I am creating a linking system that needs to be the nest component, i.e work on a hybrid app as well as a native app. The API returns a string that looks like this, Go to {P}Project Name{/P} OR Go to {F}File Name{/F} I need to search for an occurance of {P} and {F} and replace this with a <a href=""> on my webapp, and then search for {/P} or {/F} and replace that with </a> I am trying to do this with javascript but I am coming unstuck, here is what I have so far, var body = this.get('body'); if(body.match( \({P}|{F}/) { } after this I come unstuck my regex knowledge is not what it should be, can some point me in the correct direction?

Answers

0

Answer

Project

Image

Comment