• Login
Community
  • Login

How to remove unwanted space in html tags?

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
12 Posts 4 Posters 5.0k 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.
  • N
    NZ Select
    last edited by Jul 18, 2020, 10:17 PM

    @astrosofista said in How to remove unwanted space in html tags?:

    (?<=</)\x20+(?=\w+>)

    Thanks for the reply.

    I tried the code
    (?<=</)\x20+(?=\w+>)
    It does not seem to be taking an effect
    Here is the code
    https://regex101.com/r/43a61h/2

    A 1 Reply Last reply Jul 18, 2020, 10:41 PM Reply Quote 0
    • A
      astrosofista @NZ Select
      last edited by Jul 18, 2020, 10:41 PM

      Hi @NZ-Select

      The regex works fine for the provided examples, as I tested on Notepad++.

      For the new examples, try this one:

      Search: (?-s)< *?(/\w+) *?>
      Replace: <$1>
      

      Take care.

      1 Reply Last reply Reply Quote 1
      • N
        NZ Select
        last edited by NZ Select Jul 18, 2020, 11:49 PM Jul 18, 2020, 11:49 PM

        @astrosofista said in How to remove unwanted space in html tags?:

        (?-s)< *?(/\w+) *?>

        Thank you, it indeed works in Notepad++

        What if I also want to remove like < / div >, in which the forward slash and div has a space?

        Here is the screenshot:

        screenshot

        A 1 Reply Last reply Jul 18, 2020, 11:56 PM Reply Quote 0
        • A
          astrosofista @NZ Select
          last edited by astrosofista Jul 18, 2020, 11:58 PM Jul 18, 2020, 11:56 PM

          Hi @NZ-Select

          I was expecting that one :) Easy to solve, indeed, the new regex solves this and the previous ones:

          Search: (?-s)< *?(/) *?(\w+) *?>
          Replace: <$1$2>
          

          Take care.

          N 1 Reply Last reply Jul 19, 2020, 1:39 AM Reply Quote 2
          • N
            NZ Select @astrosofista
            last edited by Jul 19, 2020, 1:39 AM

            @astrosofista said in How to remove unwanted space in html tags?:

            <$1$2>

            A big thank you, it solved my problem beautifully.

            Amazing RegEx code!
            Saving me hours of work.
            And I hope it is helpful for other people who want to remove the tags as well.

            Thank you @astrosofista

            alt text

            A 1 Reply Last reply Jul 19, 2020, 2:38 AM Reply Quote 0
            • A
              astrosofista @NZ Select
              last edited by Jul 19, 2020, 2:38 AM

              Hi @NZ-Select

              You’re welcome. Glad to be of help.

              If you want to get involved in regex —is not that hard—, let me suggest you to take a look at this page:

              https://npp-user-manual.org/docs/searching/#regular-expressions

              Hope this helps.

              N 1 Reply Last reply Jul 19, 2020, 7:19 AM Reply Quote 1
              • N
                NZ Select @astrosofista
                last edited by Jul 19, 2020, 7:19 AM

                @astrosofista
                Thank you for the resource.

                W 1 Reply Last reply Jul 19, 2020, 11:25 AM Reply Quote 0
                • W
                  WinterSilence @NZ Select
                  last edited by Jul 19, 2020, 11:25 AM

                  use tiny/xml plugin

                  N 1 Reply Last reply Aug 18, 2020, 7:02 AM Reply Quote 0
                  • N
                    NZ Select @WinterSilence
                    last edited by Aug 18, 2020, 7:02 AM

                    @WinterSilence said in How to remove unwanted space in html tags?:

                    use tiny/xml plugin

                    Can you send me the url of tiny/xml plugin?
                    I searched this plugin, no result found.

                    1 Reply Last reply Reply Quote 0
                    • O
                      Olivier Thomas
                      last edited by Aug 18, 2020, 1:17 PM

                      Search: (?<!>) (?=[/>\w])
                      Replace:

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