Community
    • Login

    Regex: how to remove spaces that are not followed by letters or numbers

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    12 Posts 6 Posters 5.7k 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.
    • Claudia FrankC
      Claudia Frank @Vasile Caraus
      last edited by

      @Vasile-Caraus

      I’m confused, your example shows what should be done but is exactly what you don’t want to do as described.
      e follows the space, e is a letter. What do I miss?
      ???

      Cheers
      Claudia

      1 Reply Last reply Reply Quote 0
      • Vasile CarausV
        Vasile Caraus
        last edited by Vasile Caraus

        hello Claudia, yes, I am sorry, I tried to delete or modify the title, but was too late.

        Anyway, the example was good.

        s earch
        will become
        search

        See this little sentence to see my problem. I want to eliminate the space from the interior of words, without joining the other words.

        focu s on the opposition be tween the apparent simplicity of prod ucing a distinct creation and its ulterior comple xity

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

          …and j ust ho w in the heck is the reg ex eng ine suppose d to know w hich space is a space betw een words and which spac e is a space ins ide a wor d?

          :-D

          Vasile CarausV 1 Reply Last reply Reply Quote 2
          • Vasile CarausV
            Vasile Caraus @Scott Sumner
            last edited by

            @Scott-Sumner

            hello Scott. I really don’t know…

            1 Reply Last reply Reply Quote 0
            • guy038G
              guy038
              last edited by

              Hello Vasile,

              Scott is perfectly right about it !! How the regex engine could guees, for instance, than the two words be and tween are finally the single word between ? And anyway, the first word be is quite a valid English word, isn’t it ?

              So I would advice you to use, rather, a Spell-checker plugin, which will, automatically, highlight all the non-correct words of your text

              Best Regards,

              guy038

              1 Reply Last reply Reply Quote 0
              • AdrianHHHA
                AdrianHHH
                last edited by

                See also http://www.davidpbrown.co.uk/poetry/martha-snow.html

                1 Reply Last reply Reply Quote 3
                • Js jSJ
                  Js jS
                  last edited by

                  where did the original text come from?

                  how were the spaces introduced into the text?

                  maybe there is a pattern that can be used to identify the “bad” spaces

                  1 Reply Last reply Reply Quote 0
                  • Vasile CarausV
                    Vasile Caraus
                    last edited by Vasile Caraus

                    hello, Js. This is what I am trying to figure out.

                    Right now I am trying some combination like this one:

                    Search: \x20?\x20
                    Replace by: $1

                    Is not quite very good, but I have time to check more things. I got to have luck :D

                    But I need to make some kind of a connection with a dictionary, with a spell check.

                    1 Reply Last reply Reply Quote 0
                    • Js jSJ
                      Js jS
                      last edited by

                      you have not answered the question.

                      where did the text come from? … was it downloaded from website?

                      how were the spaces introduced?

                      were there other characters in the text, like html tags that someone incorrectly deleted by replacing tags with spaces?

                      1 Reply Last reply Reply Quote 0
                      • Vasile CarausV
                        Vasile Caraus
                        last edited by

                        oh, sure. The text was made after using a pdf to txt converter.

                        1 Reply Last reply Reply Quote 0
                        • Js jSJ
                          Js jS
                          last edited by Js jS

                          ouch!!

                          try opening the original pdf file using Notepad++
                          you may get lucky, and the contents may be cleartext (not compressed)

                          otherwise, try a different pdf to txt converter or try ocr software

                          good luck

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