locked
how to modify one html string RRS feed

  • Question

  • User450763225 posted

    Hi, I am trying to modify some html string with jquery, for example, I have the below:  

    @#letterDate#@, @#name#@,  

    these should be replace by other data, should use regexp ?

    Monday, August 8, 2016 1:56 AM

Answers

  • User-693045842 posted

    try this :

    var result ="The first instalment charge will be made to your ANZ Credit Card (#@CreditCardNumber@#) ".replace("@#CreditCardNumber#@", Your value)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 8, 2016 5:10 AM

All replies

  • User1724605321 posted

    Hi sdnd2000,

    You could try the replace function in jquery :

            var str ="@#letterDate#@, @#name#@";
            var result= str.replace("@#letterDate#@", "aaa"); 

    Best Regards,

    Nan Yu

    Monday, August 8, 2016 3:13 AM
  • User450763225 posted

    Hi, Nan,

    Thanks the help.

    I mean what if the strings in a statement, like below, and I want replace that with  real data

    The first instalment charge will be made to your ANZ Credit Card (#@CreditCardNumber@#) on #@inputDate@# based on the amount 

    Monday, August 8, 2016 3:30 AM
  • User-693045842 posted

    Then you want to replace "#@CreditCardNumber@#" with the real number in a string ? 

    Monday, August 8, 2016 4:57 AM
  • User450763225 posted

    yes

    Monday, August 8, 2016 5:07 AM
  • User-693045842 posted

    try this :

    var result ="The first instalment charge will be made to your ANZ Credit Card (#@CreditCardNumber@#) ".replace("@#CreditCardNumber#@", Your value)

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 8, 2016 5:10 AM
  • User450763225 posted

    still need get the whole sentence, so only regexp can find the exact pattern, and replace it?

    Monday, August 8, 2016 5:26 AM
  • User-693045842 posted

    what do you mean by "still need get the whole sentence," ?

    Monday, August 8, 2016 6:55 AM