Regex Cheat Sheet



A quick cheat sheet for using Notepad++ to find and replace arbitrary text in Notepad++.

In all examples, use select Find and Replace (Ctrl + H) to replace all the matches with the desired string or (no string).

Cheat Sheet This cheat sheet is intended to be a quick reminder for the main concepts involved in using regular expressions and assumes you already understand their usage. If you are new to regular expressions we strongly suggest you work through the Regular Expressions tutorial from the beginning. Regex cheat sheet of all shortcuts and commands. Match a single white space character (space, tab, form feed, or line feed). Regular Expressions / Regex Cheat Sheet Special Characters in Regular Expressions & their meanings. Character Meaning Example. Match zero, one or more of the previous. Regex Cheat Sheet. GitHub Gist: instantly share code, notes, and snippets.

And also ensure the ‘Regular expression’ radio button is set.

1. Removing arbitrary whitespaces and tabs

In this example we replace the whitespaces and tabs between pairs of ‘><' strings

Regex match expression:

Regex cheat sheet r

(Be sure to use capital ‘R’, switch off word wrap so you can see it merge into one line)

Regex Cheat Sheet

Replace with:

Result

2. Insert a newline for every line of text

Regex match expression:

Replace with:

Sheet

Result:

3. Removing blank lines

Regex match expression:

Replace with:

Result:

4. Replace comma separated list with string list

Regex match expression:

Replace with:

n

Result:

5. Remove duplicate words

Regex match expression (simple):

Replace with:

1

Result:

6. Replace with first word from each line

Regex match expression (simple):

Replace with:

1

Result:

7. Replace with last word from each line

Regex match expression (simple):

Regex Cheat Sheet Php

Replace with:

Result:

8. Replace all duplicate lines with a single instance

Regex match expression:

Replace with:

Result:

9. Insert all text into a single line

Check that your word wrap is switched off so that you actually see the text get modified.

Buy virtual set vmix. Regex match expression:

R

Replace with:

Result:

10. Replace the first line in text

In this example we just replace the match with empty text.

Regex match expression:

Regex cheat sheet js

A.*

Replace with:

Result:

11. Trim additional spaces from sentences

In this example we remove trailing and leading whitespaces from sentences. Original link.

Regex Cheat Sheet Splunk

Regex match expression:

Regex Cheat Sheet

^[s]*(.*?)[s]*$

Regular Expression Cheat Sheet Python

Replace with:

Regex Cheat Sheet Java

Result: