0% found this document useful (0 votes)
206 views18 pages

The Power of Regular Expression Use in Notepad++

The document discusses using regular expressions in Notepad++ to remove numbers from a list of names, swap numbers and names with a comma separator, and remove numbers while rearranging names with last name first and a comma separator.

Uploaded by

David Powell
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
206 views18 pages

The Power of Regular Expression Use in Notepad++

The document discusses using regular expressions in Notepad++ to remove numbers from a list of names, swap numbers and names with a comma separator, and remove numbers while rearranging names with last name first and a comma separator.

Uploaded by

David Powell
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 18

A look at the power of Regular Expressions for the layman

Use in Notepad++

Anjesh Tuladhar http://anjesh.blogspot.com http://just-tech.blogspot.com

Alert

Dont expect to master regular expressions (regex) in this short presentation.


This shows how you can exploit regex to make your work a breeze It takes a lot of time and hard work to learn regex

You dont have to be a programmer to master regular expressions, though being a programmer is definitely a plus point

Remove numbers from the list of 1000 rows of names

Choose Replace from Search menu

You will get a replace dialog box.

Type [0-9]* (.*) in find what box, \1 in replace with box. Note: Theres a space between [0-9]* and (.*).

Check Regular Expression checkbox to exploit regex functionality.

Hurray! Done.

A short explanation

[0-9]* will match numbers only


In our case it matches numbers only

.* will match any characters, including numbers till the end of the line
Use of the curve brackets will act as a memory Enclosing .* with brackets like (.*) will allow to access it using \1 (see in the replace box)

The space between [0-9]* and (.*) represents the actual space between numbers and the names in the list

Now you have to swap numbers and names, but separated by comma.

Type ([0-9]*) (.*) in find what box, \2,\1 in replace with box.

Replaced!

A short explanation

See previous explanation for [0-9]* and (.*) Now enclosing [0-9]* with curve brackets will allow to access it First curve bracket can be accessed using \1 and second can be accessed using \2
Hence we are swapping the position of names and numbers

Now you have to remove numbers, put last-name first, followed by first-name, and separated by comma.

Type ([0-9]*) ([^ ]*) (.*) in find what box, \3,\2 in replace with box.

Replaced!

A short explanation

[0-9]* will match numbers only [^ ]* will match anything from the current position till it finds space, which in our case will match the firstnames only .* will match any character from the current position till the end of the line Now [0-9]* is accessed using \1, [^ ]* is accessed using \2 and .* is access using \3, since all of those expressions are enclosed with curve brackets

The beginning

Make today

a noble beginning
with The Regular Expressions

You might also like