Forum Discussion

SocInABox's avatar
SocInABox
Iron Contributor
Dec 15, 2021

Logic app search replace function usage example?

Can someone please give me an example function for search and replace?
I'm using html in the sentinel 'add comments' operator and I'm seeing lots of \n characters.
I want to remove them all so they don't write line feeds to the output and mess up my html markup.

Thank you.
  • hi SocInABox 

     

    Not sure if it's the same, but, I've feced something similar with an HTML table where I wanted to include a hyper link using <a href> and Logic App replaced those chars. 

     

    What I did was process the HTML content before using it (Send Email) as an expression 

    replace(replace(variables('email_html'), '&lt;', '<'), '&gt;', '>')
     
    Maybe my scenario is simplier than the one you have but hope it helps
  • hi SocInABox 

     

    Not sure if it's the same, but, I've feced something similar with an HTML table where I wanted to include a hyper link using <a href> and Logic App replaced those chars. 

     

    What I did was process the HTML content before using it (Send Email) as an expression 

    replace(replace(variables('email_html'), '&lt;', '<'), '&gt;', '>')
     
    Maybe my scenario is simplier than the one you have but hope it helps
    • SocInABox's avatar
      SocInABox
      Iron Contributor

      Hey cmaneiro, thanks! that worked for me.

      Took me a minute to realize your example was a 'replace inside of a replace', which was more than i needed.

       

      I was able to replace all of the html content containing '\n' with ''   ('' = nothing).

       

      So my solution was:

      - collect all variables (which contain html markup) and assign them all to a single variable.

      - replace all \n values with nothing.

      - use the cleaned up variable in my Sentinel Incident comments.

       

      The result is a much better formatted html with only one line feed between the text body and the table (before there were 8 linefeeds!)

       

       

  • raffellis's avatar
    raffellis
    Copper Contributor
    I have a large document that is riddled with paragraph symbols in the wrong place

Resources