Menu

Notepad ++ Expressions

2008-03-28
2012-11-13
  • Nobody/Anonymous

    I am attempting to remove spaces after a semi colons so that the letters or numbers are indented left. Here is an example:

    john;   smith;    123 Main Street; anywhere;           abc@email.com;   123xyz

    I want it to read:

    john;smith;123 Main Street;anywhere;abc@email.com;123xyz

    I have tried to "kill all white spaces, but it gets rid of spaces I need such as in the address and other places. I tried this expression and it didn't work

    (; )[^A-Za-z0-9]

    No luck. Any help would be great. I have to rectify this with a text document with 1000 lines. Thank you for your consideration.

     
    • Nobody/Anonymous

      Find field:
      ; ([A-Za-z0-9]*)

      Replace field:
      ;\1

      The asterisk * means: any number, including 0, of matches of the supplied character set.
      The parentheses take this as a group which will be put back in the replace field by stating \1. The space is removed, the ; is placed back also. Including 0 matches will also remove the ending space on lines ending with "; ".

      If there are possibly more than one space characters, put a + sign after the single space in the Find field.

      [^A-Z] means: NOT matching any of the characters in the range A to Z.

       
      • Nobody/Anonymous

        An easier approach will not necessarily lead to correct results.

        Find field:
        ; +

        Replace field:
        ;

         
        • Nobody/Anonymous

          This one may possibly be the safest. Note that when you copy lines from the forum, possibly a space character will be appended to each line. Remove those from the criteria.

          Find field:
          ; +([^;]*)

          Replace field:
          ;\1