Regular Expression on EditPlus

9 Aug

Howto Use Regular Express On Editplus For Work!!!!

Remove all empty lines:

Find: “^\n” (Ignore double-quotes in all find/replace)
Replace: “”
Where,
^ <–>Beginning of the line
\n <–>New Line

Remove Multiple Spaces convert into single space:

Find: ” +”
Replace: ” “
Where,
+ <–>find one or more occurance of space character.

Comment multiple line of code:

Find: “^”
Replace: “#” or “//”
You may optionally use: Edit Menu > Format > Line Comment.
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 “”.

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
Eg:
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: “”

Remove lines not containing a given STRING:

I don’t know how to do this!! :)

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″
Eg.:
Original: 1231231231
Formatted-1: 123-123-1231

Remove Brackets:

Find: “\(|\)”
Replace: “”
Where,
\( – Match (. \ is required to escape marking the expression.
| – or

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 times.
  • + – 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 “\\”.

Reference : http://kedar.nitty-witty.com/blog/working-with-editplus-text-editor-regular-expression-how-to

4 Responses to “Regular Expression on EditPlus”

  1. James Buccelli May 20, 2012 at 4:49 am #

    I really enjoyed reading this article. I’m actually committing Sin #2 ‘Waiting too long to comment’! However, I felt compelled to express appreciation, since I think many of these you enumerate are unconscious mistakes that can easily be rectified.

  2. Kelle Arnspiger May 22, 2012 at 7:34 am #

    Hi there! I’ve just stopped by to thank-you for this nice blog post! Keep going that way.

Trackbacks/Pingbacks

  1. gay porn - May 24, 2012

    Title…

    Man that was strange. I just wrote an extremely detailed comment but after I clicked submit my comment didn’t show up. Sigh well I’m not typing all that again. Anyways, just wanted to say fantastic blog…almost as cool as http://facebook.com!…

  2. scissor lift for sale - May 25, 2012

    Title…

    Ugh, I just typed a long comment, but it disappeared when I clicked send. Anyway, I’m not going to retype it again, so I just wanted to say cool blog! Better than http://google.com! :-)…

Leave a comment