Community
    • Login

    Can I find/replace instances where paragraph tags are followed by a lowercase letter?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    replacesearch
    6 Posts 3 Posters 1.4k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • theevilwriterT
      theevilwriter
      last edited by

      Is there a way to do this specific find and replace?

      I’ve used a website to remove hard line breaks from old docs that were broken into 70 characters per line, which converts them into html as it removes the line breaks. It works fairly well, but there are times when it adds a new paragraph when it shouldn’t have, mid-sentence, and it’s taking a fair amount of time to remove them manually…

      So is there a way to replace instances of </p> <p>firstletterislowercase with space firstletterislowercase?

      And if I can’t do a search and replace like that, can I at least design a find that will show me all instances when <p> is followed directly by a lowercase letter so I don’t need to read the whole document to find each one?

      Thank you!

      Scott SumnerS 1 Reply Last reply Reply Quote 0
      • Scott SumnerS
        Scott Sumner @theevilwriter
        last edited by Scott Sumner

        @theevilwriter

        Try this:

        Find what zone: (?-i)</p> <p>([a-z])
        Replace with zone: \1
        Search mode: Regular expression

        Note that there is a space between the tags because YOU had one there in your data (it may or may not be there in reality), and also note that there is a space before the \1 in the replace string (that one is hard to see). Could also use \x20\1 as the replace string which makes it way more obvious.

        1 Reply Last reply Reply Quote 2
        • theevilwriterT
          theevilwriter
          last edited by

          It says that it doesn’t find any instances, even with the cursor placed on the line above an example like:

          <p>She</p>

          <p>gave him one of her brilliant grins and wandered into the kitchen to correct his faux-pas.</p>

          I tried doing a find and replace so instead of being on different lines the paragraph tags were one after another without spaces (</p><p>) and it still couldn’t find any.

          1 Reply Last reply Reply Quote 0
          • theevilwriterT
            theevilwriter
            last edited by

            I think it’s working now. For some reason, it can find </p> <p> but not </p><p> regardless of whether the replace term has a space.

            Anyway, thanks!!

            1 Reply Last reply Reply Quote 0
            • PeterJonesP
              PeterJones
              last edited by

              @theevilwriter ,

              You do realize that @Scott-Sumner explicitly said “Note that there is a space between the tags because YOU had one there in your data (it may or may not be there in reality)”. He told you that it would only work with a space between the </p> and the <p>. I am not sure why you were surprised.

              And you said, “it can find … regardless of whether the replace term has a space”: why would you think that the replace term would affect what text the find matches?

              If you want to learn how to understand the regular expression syntax that @Scott-Sumner used, please see this FAQ. By studying the documentation, you could probably learn how to customize it to meet your changing requirements. If you still cannot figure out how to do exactly what you want, show what you tried, why you tried that (ie, why you chose the modifications you did), what you got, and what you expected, and we’ll probably be able to help you more. If you don’t show any additional effort, no amount of giving you new regexes will truly help you.

              Scott SumnerS 1 Reply Last reply Reply Quote 2
              • Scott SumnerS
                Scott Sumner @PeterJones
                last edited by

                @PeterJones said:

                You do realize…

                LOL … amazing… (sigh)

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post
                The Community of users of the Notepad++ text editor.
                Powered by NodeBB | Contributors