2 Replies Latest reply on Aug 26, 2016 3:18 AM by kettan

    replace html <span style="font-size:12px"> with space

    Love Walk'g

      I have <span style="font-size:12px"> come in as part of Html tag with my raw data that I need to get ride of.

       

      so I use :

       

      replace ("<span style="font-size:12px">", "">

       

      However it has syntax error! please see attachment. is that becuase the qutation mark?

       

      Thank you in advance!

        • 1. Re: replace html <span style="font-size:12px"> with space
          Matthias Goossens

          Hey Love,

           

          Could you try this one:

           

          replace("<span style=""font-size:12px"">", "<span style=font-size:12px>","")

           

           

          Matthias

          • 2. Re: replace html <span style="font-size:12px"> with space
            kettan

            Your calculation has 3 issues, which are explained under title ISSUE 1-2-3 below.

             

             

            CALCULATION WITH ISSUE

             

            replace ("<span style="font-size:12px">", "">

             

             

            CALCULATIONS THAT WORK

             

            replace( [HTML field], '<span style="font-size:12px">', "" )

            replace( [HTML field], "<span style=""font-size:12px"">", "" )

             

             

            ISSUE 1:  You forgot to include your field in the REPLACE condition:

             

            REPLACE(string, substring, replacement)

             

            Searches string for substring and replaces it with replacement.

            If substring is not found, the string is not changed.

             

            Example

            REPLACE("Version8.5", "8.5", "9.0") = "Version9.0"

             

            http://onlinehelp.tableau.com/current/pro/desktop/en-us/help.htm#functions_functions_string.html

             

            replace ("<span style="font-size:12px">", "">

            replace ([HTML field], "<span style="font-size:12px">", "">

             

             

            ISSUE 2:  Typing error for end parenthesis, which should be ")" rather than ">".

             

            replace ([HTML field], "<span style="font-size:12px">", "">

            replace ([HTML field], "<span style="font-size:12px">", "")

             

             

            ISSUE 3:  The substring contains " which is the same as its qualifier.

             

            There are two workarounds.

             

            a. Use apostrophe (') as substring text qualifier:

             

            replace ([HTML field], "<span style="font-size:12px">", "")

            replace ([HTML field], '<span style="font-size:12px">', "")

             

            b. Use two ("") for text to replace when it is the same as the text qualifier, "" means " in this context:

             

            replace ([HTML field], "<span style="font-size:12px">", "")

            replace ([HTML field], "<span style=""font-size:12px"">", "")

            2 of 2 people found this helpful