9 Replies Latest reply: Sep 25, 2014 9:22 AM by Captiv8r RSS

    A Find expression to find everything in span tag

    jeffc2010 Community Member

      I imported word doc into my robohelp project and there is a lot of span tag junk i want to get rid of.

       

      Is there an expression i can build in the "find and replace" tool that will find any span tag and its contents?

      In the following example I want to delete the whole string including the brackets:

       

      <span style="letter-spacing: .05pt;">

       

      I'm thinking possibly a wildcard like: <span ***>

       

      I don't see a wildcard option in robohelp help related to building find expressions.

        • 1. Re: A Find expression to find everything in span tag
          Willam van Weelden CommunityMVP

          Hi,

           

          Are you using RoboHelp 8 or above? If so, you can use a script for that. (I have one lying around somewhere, let me know if you're interested.)

           

          If you want to search, don't search for <span, as that will remove span tags you want to retain (styles, expandtexts, etc.) I'm not very comfortable with regular expressions, but Peter might know a fancy regex.

           

          @Peter: Hello! Can you chime in?

           

          Greet,

           

          Willam

          • 2. Re: A Find expression to find everything in span tag
            Peter Grainge CommunityMVP

            Nasty one this as you cannot search for <span - and all between - and </span> without trashing a lot of stuff that is needed.

             

            In theory if you have Rh10 you could add a must include but there are two issues there. It sounds like there could be many must includes and there is a bug in the Must Include part of the new Find and Replace in Files so you don't want to use it anyway.

             

            I'm thinking you want to avoid those tags in the first place. It sounds like the source document has inline formatting that needs to be removed.

             


            See www.grainge.org for RoboHelp and Authoring tips

             

             

            @petergrainge

            • 3. Re: A Find expression to find everything in span tag
              jeffc2010 Community Member

              I am using tech com suite 10. I don't mind using an expression that could delete any span tag and its values because i can do "find next" to keep what i need.

               

              I would have preferred not importing the word doc and all its span tag formatting, but i needed a detailed table that i did not want to reproduce from scratch --so i traded one problem for another one.

               

              William, thank you for the offer of a script.  are there any instructions for using it? i'm not familiar with running scripts in robohelp. i would like to look at it. maybe i can figure it out.

               

              Peter, i am hoping for an "and everything in between" like a wildcard because there are variations in various span tag values i want to get rid of.

               

              How 'bout another alternative: how can i get a table from word to robohelp where all i want to retain is column/row structure and each cell's text content? --without text formatting?

               

              Also, how 'bout a 3rd party html editor that enables me to build this type of expression. I also have dreamweaver CS6.

              • 4. Re: A Find expression to find everything in span tag
                Peter Grainge CommunityMVP

                Tools that handle regular expressions are not the problem, it's writing the expression that requires the time and skill.

                 

                If you are just looking for everything starting <span and ending </span> you don't need regular expressions, I think Rh's Find and Replace in Files will do it, just don't use the Must Include field and make sure you have a backup of your project.

                 

                Now that we know your version of Rh, apply a style to your tables in Word (create a named style if you have to) and create a table style in Rh. When you import you can map the two and then the table should be good.

                 

                Importing is covered on my site and I think mapping tables is in the Rh9 section of my RoboHelp Tour.

                 


                See www.grainge.org for RoboHelp and Authoring tips

                 

                 

                @petergrainge

                • 5. Re: A Find expression to find everything in span tag
                  jeffc2010 Community Member

                  Actually, i wanted to keep the text between the opening and closing span tags, so i am seeking an expression that finds everyting inside the opening span tag:

                   

                  for example, find any opening span tag, including all the styling attributes:

                   

                  <span style=various styling attributes ">

                   

                  I ran across the following regular expression, but it misses some span tags (i don't know why)

                   

                  <span(.*)">

                  • 6. Re: A Find expression to find everything in span tag
                    jeffc2010 Community Member

                    peter,

                    about importing tables: i am importing a word doc that has a simple table (albeit there are several rows and columns). I am using the RH word options on import to match styles.

                     

                    It still creates bizarre span styles breaking a single cell's content into multiple tags like the following:

                     

                    <span style="font-size: 9.0pt;

                       font-family: Arial, sans-serif; letter-spacing: .05pt;">d</span><span

                       style="font-size: 9.0pt; font-family: Arial, sans-serif;">Bm</span>

                     

                    As you can see, it splits cell content into multiple tags. In this case the cell text is "dBm"

                     

                    i don't know what is doing what to what, but i would like to figure out how to get rid of all the extraneous span tags while keeping the cell text.

                    • 7. Re: A Find expression to find everything in span tag
                      Peter Grainge CommunityMVP

                      Humour me.

                       

                      1. Create a Word document with a table that has a named style applied.
                      2. Create a Rh project with a table style given the same name. It does not have to look the same and it might be better if it does not, you will know whether or not the mapping is working.
                      3. Import making sure you map the table styles.

                       

                      Do you still have unacceptable span tags?

                       

                      If the above idea does not solve the problem, give me some examples of your span tags, especially the ones where your expression is not working. I will try to come up with something but it might take a day or two before I can get back to you.

                       


                      See www.grainge.org for RoboHelp and Authoring tips

                       

                       

                      @petergrainge

                      • 8. Re: A Find expression to find everything in span tag
                        Maryann8 Community Member

                        I use a regular expression and notePad++ to delete all span tags, but leave their content.

                        Be careful, always test regular examples on test files first.

                         

                        Caution: this regular expression will remove all your opening and closing span tags.

                        Even the ones you are fond of.

                         

                        Search for this:

                        </?span[^>]*>

                         

                        Replace with nothing (empty string)

                        • 9. Re: A Find expression to find everything in span tag
                          Captiv8r CommunityMVP

                          Hi there

                           

                          If the goal is to simply remove spans, all you really have to be concerned with is removing the opening span tag. In my experience, RoboHelp is smart enough to see an orphaned closing span tag and just discard it as a routine practice.

                           

                          Cheers... Rick