Working with EditPlus Text Editor-Regular Expression How To

Editplus is a lot better than the regular text editor, Notepad. From all it’s features I like RegExp Support the most, and than comes the block select feature. Here are the quick lines to carry out regular tasks using regular expression in Editplus. Most steps will also work with other editors supporting regular expressions like Notepad++.

It’s kinda downloadable editplus regular expression cheetsheet list.

How To Remove all empty lines in EditPlus or Notepad++

Find: "^\n" (Ignore double-quotes in all find/replace)
Replace: ""

Where,
^ - Beginning of the line
\n - New Line


How To Remove Multiple Spaces convert into single space in EditPlus or Notepad++

Find: ” +”
Replace: ” “
Where,

How To Find one or more occurance of space character EditPlus

Comment multiple line of code:
Find: "^"
Replace: "#" or "//"
You may optionally use: Edit Menu > Format > Line Comment.

How To Generate Comma Separated List from new line delimited list

Find: "\n"
Replace: ", "
This helps in even joining some of lines of code instead of replacing by comma you may replace it with "".

How To Manipulate columns display order / punctuation


Find: "([0-9]+)\t([a-zA-Z]+)"
Replace: "\2\t\1"

Where,
[0-9]+ - Finds one or more digits
[a-zA-Z]+ - Finds one or more characters
() - mark the block or capture the group
\2 - 2nd mark expression

For example original text as follows:
123 abc
345 cde
567 efg

becomes:
abc 123
cde 345
efg 567

The Other Way:

- Press Alt+C
- Drag you mouse to select respective column and click
- Copy / Cut as required

Append / Add semicolon (any character) at the end of the line

Find: "\n"
Replace: ";\n"

Enclose lines by quotes

Find: "\n"
Replace: "'\n'"

Delete all lines containing a given STRING

Find: "^.STRING.$"
Replace: ""


How To Remove lines not containing a given STRING

I don’t know how to do this!! ๐Ÿ™‚

How To Convert tab separated file into insert statements


TSV: abcd de4 iirn 34399
SQL: INSERT INTO TABLENAME VALUES ("abcd", "de4", "iirn","34399");
Find: "(.)\t(.)\t(.)\t(.)"
Replace: "INSERT INTO TABLENAME VALUES ("\1", "\2", "\3","\4");"
Format the telephone number:
Find: "([0-9][0-9][0-9])([0-9][0-9][0-9])([0-9].*)"
Replace: "\1-\2-\3"
For example:
Original: 1231231231
Formatted text becomes: 123-123-1231

How To Remove Brackets

Find: "(|)"
Replace: ""
Where,
( -> Match (. \ is required to escape marking the expression.
| -> or

How To Replace 1st occurrence of character


Find: " (.)" Replace: "-\1" Where, (.) - matches everything and marks the block
** Make sure you ignore double-quotes(") while writing in find / replace boxes.
EditPlus supports following regular expressions in Find, Replace and Find in Files command.
Expression - Description
\t - Tab character.
\n - New line.
. - Matches any character.
| - Either expression on its left and right side matches the target string.
[] - Any of the enclosed characters may match the target character.
[^] - None of the enclosed characters may match the target character.
- Character to the left of asterisk in the expression should match 0 or more time.
- Character to the left of plus sign in the expression should match 1 or more times.
? - Character to the left of question mark in the expression should match 0 or 1 time.
^ - Expression to the right of ^ matches only when it is at the beginning of line.
$ - Expression to the left of $ matches only when it is at the end of line.
() - Affects evaluation order of expression and also used for tagged expression.
\ - Escape character. If you want to use character "\" itself, you should use "\".

Notable Features of Editplus are

Spell checking
Regex-based find & replace
Encoding conversion
Newline conversion
Syntax highlighting
Multiple undo/redo
Rectangular block selection
Auto indentation
Code folding (Text folding)

Download pdf: Editplus-RegExp.

Conclusion: EditPlus, with its support for regular expressions, offers a versatile platform for efficient text editing and manipulation. By mastering the techniques covered in this article, you can harness the full power of regular expressions in EditPlus to streamline your workflow, automate repetitive tasks, and achieve cleaner and well-formatted text. Take advantage of features like spell checking, encoding conversion, syntax highlighting, and more, as EditPlus empowers you to become a proficient text editor. With regular expressions as your tool, the possibilities are endless in EditPlus. Elevate your text editing game and unlock new levels of productivity with these invaluable tips and tricks.

58 comments
  1. Hi Kedar, Could you help me?
    Iยดm using EditPlus to modify some TXT files;
    I have this info on those TXT files:

    Fri Jul 19 02:13:01 CDT 2013
    Usage: 370868224
    Fri Jul 19 02:18:00 CDT 2013
    Usage: 370868224
    Fri Jul 19 02:23:00 CDT 2013
    Usage: 370868224
    Fri Jul 19 02:28:00 CDT 2013
    Usage: 370868224

    And I need to that info in this format:

    Fri Jul 19 02:13:01 CDT 2013 Usage: 370868224
    Fri Jul 19 02:18:00 CDT 2013 Usage: 370868224
    Fri Jul 19 02:23:00 CDT 2013 Usage: 370868224
    Fri Jul 19 02:28:00 CDT 2013 Usage: 370868224

    Could you tell me, how can I do that change using editplus?

    Thanks & regards.

    1. Hey Eric,

      Not sure how did I miss this but still the answer to this is easy:

      Find: “\nUsage”
      Replace: “Usage”

      Apologies for hell lot of delay but hope this helps some other time. ๐Ÿ™‚

  2. I was hoping you could help me with this issue

    Original line:
    $427SCANN.HECSB-DGSESC.CAMPUS

    New Line:
    $427SCANN.HECSB-DGSESC.CAMPUS
    changetype: modify
    replace: uid
    uid: $427SCANN

    I need to grab the first portion of the line to the first dot, keep the original line, add the 3 new lines and add the captured first portion to uid:.

    Hope you can help.

    1. Hey McDrom,

      Sorry for delayed response but here is the answer:

      Find: (.*)\.(.*)\.(.*)
      Replace: \1.\2.\3\nchangetype: modify\nreplace: uid\nuid: \1

      Cheers…

      1. Hey Kedar,

        i want add a quote ‘ in the beginning of a word and end of word , how can i do it in edit plus

        1. Hi Divya,

          I’m not sure if that’s a single word or for each word but I’d give you an example and that should suffice your needs:

          1) Replace at the beginning of the line:
          Find: “^”
          Replace: “`”
          2) Replace after word ends
          Find: “([0-9A-Za-z]) ”
          Replace: “\1` ”
          3) Replace at the end:
          Find: “\n”
          Replace: “`\n”

          * Ignore double quote (“) and note the spaces.

          Hope this helps…. cheers.

  3. Hi Kedar,

    You are really helpful. Thanks for your efforts.

    Can you please explain us how to do the following?

    Example:

    Sample one
    Sample two
    Sample three
    (having more than 20,000 lines)

    I need to replace as below

    Sample one
    go
    Sample two
    go
    Sample three
    go

    Can you please help me?

    Thanks.

  4. Delete all lines containing a given STRING:

    Find: โ€œ^.*STRING.*$โ€
    Replace: โ€œโ€

    This works fine and the entire line is deleted, however the blank line remains, how to delete that so that the line below comes up as in xlUp?

    1. That’s easy akshayee,

      To remove blank lines you may:
      Find: \n\n
      Replace: \n

      Or directly:
      Find: “^.*STRING.*\n”
      Replace: “”

      ๐Ÿ™‚

  5. hello I need to replace

    (1 nickname2
    (2 nickname33
    (3 nickname234
    (4 nickname21
    ..(365355 nickname54

    to

    nickname2
    nickname33
    nickname234
    nickname21
    nickname54

    what is the expresion to use ?

    thank you

  6. I had a very big file and i used the search to find what i want and i did set marker for those line. How can i remove other lines which are not set to marked and copy only the lines which are set to marked.

    1. Sruhi,

      Sorry for the too much delayed response!
      Well as written in the post “Remove lines not containing a given STRING:” is something I don’t know yet; It’s possible through some Linux Commands but editplus.. sorry ๐Ÿ™

      Well I hope you must have overcome this issue by hook/crook though!

      Thanks for visiting,
      Kedar.

      1. Remove lines not containing a given STRING

        Find “^.*STRING.*$” and set the marker. then go to Edit -> Delete -> Delete Un Marked lines.

        ๐Ÿ™‚ just to complete your post.

  7. Can you tell how to truncate a line from a given char or string . what i wanted is as follows .

    IND vs PAK – Delhi
    AUS vs ENG – Dhaka

    i want these to become
    IND vs PAK
    AUS vs ENG

    ie trucate the line from the char “-” .

  8. Thanks on your help
    If you find how to delete only lines or exprssion that not contain a given String I happy to know
    Or, if you know any other Program that allow that.
    Thanks
    Yoni

  9. Hi Bar,
    ^ here represents Beginning of a line while $ represents end of the line.
    So from the beginning (^) to end ($) delete lines whichever contains STRING.

    eg.

    this is the line
    this is the line too

    From above two lines if I replace using:
    ^this is the line$
    only first line will get replaced but second.

    I hope I’m making sense.

  10. Thank on your wondeful guide.
    can you please explain why you the *Caret* ^ here?
    Delete all lines containing a given STRING:
    Find: โ€œ^.*STRING.*$โ€
    Replace: โ€œโ€
    Thanks again
    Bar

Leave a Reply

Your email address will not be published. Required fields are marked *