regex - Replace spaces with colon (:) in Notepad++?

07
2014-07
  • Farid

    Suppose (this is sample data) I have these lines:

    A                          W
    BAKER                      X
    CANDLESTICKMAKER           Y
    DOGCATCHER                 Z
    

    I want to change the whitespace to colons, like this:

    A:W
    BAKER:X
    CANDLESTICKMAKER:Y
    DOGCATCHER:Z
    

    How can I achieve this in Notepad++?

  • Answers
  • Oliver Salzburg

    Replace + ( followed by +) with ::

    enter image description here

    Make sure Regular expression is checked.

    As igalvez pointed out in his comment, you might want to use ( |\t)+ to also match \t (the tab character).

    One might want to use \s to match all whitespace, but that will also match the line breaks and condense your whole data to a single line.


  • Related Question

    Notepad++ Search & Replace with Regular Expressions
  • Jeremy

    I know its simple, but I can't get it to work...

    I have a strings like

    {span style="display:none"}123{/span} and 
    
    {span style="display:none"}456{/span} and 
    
    {span style="display:none"}789{/span}
    

    in a file.

    I want to remove all of these string.

    So, I thought a simple regular expression replace in NotePad++ should be like

    {span style="display:none"}[(.)]{/span}
    

    but, this is not working.

    Thank for your help!


  • Related Answers
  • FrEaKmAn

    You were close

    {span style="display:none"}(.*){/span}
    
  • Jeremy

    Found it!

    Now using {span style="display:none"}[0-9a-zA-Z_&-. ]+{/span} in the search box!