Download regex replace system PDF

Titleregex replace system
TagsTypes Brochures
File Size1.1 MB
Total Pages86
Document Text Contents
Page 1

29 June 2008

The information in this post details how to clean up DMDX .zil files, allowing for easy importing into
Excel. However, the explanations following each Find/Replace term will benefit anyone looking to
understand how to use Notepad++ extended search mode and regular expressions.

If you are specifically looking for multiline regular expressions, look at this post.

You may already know that I am a big fan of Notepad++. Apparently, a lot of other people are
interested in Notepad++ too. My introductory post on Notepad++ is the most popular post on my
speechblog. I have a feeling that that is about to change.

Since the release of version 4.9, the Notepad++ Find and Replace commands have been updated.
There is now a new Extended search mode that allows you to search for tabs(\t), newline(\r\n), and
a character by its value (\o, \x, \b, \d, \t, \n, \r and \\). Unfortunately, the Notepad++ documentation
is lacking in its description of these new capabilities. I found Anjesh Tuladhar's excellent slides on
regular expressions in Notepad++ useful. After six hours of trial and error, I managed to bend

Notepad++: A guide to using regular expressions and
extended search mode

► 2013 (3)

► 2012 (2)

► 2011 (4)

► 2010 (2)

► 2009 (7)

▼ 2008 (11)
► October (1)

► August (3)

► July (2)

▼ June (2)
Notepad++: A guide to using

regular expressions an...

Create conference posters:
From Powerpoint to high...

► May (1)

Blog Archive

Share 36 More Next Blog» Create Blog Sign In

Do you need professional PDFs? Try PDFmyURL!

http://markantoniou.blogspot.com/
http://markantoniou.blogspot.com/2009/02/regular-expressions-guide.html
http://markantoniou.blogspot.com/2007/09/notepad-start-using-real-text-editor.html
javascript:void(0)
http://markantoniou.blogspot.com/search?updated-min=2013-01-01T00:00:00%2B11:00&updated-max=2014-01-01T00:00:00%2B11:00&max-results=3
javascript:void(0)
http://markantoniou.blogspot.com/search?updated-min=2012-01-01T00:00:00%2B11:00&updated-max=2013-01-01T00:00:00%2B11:00&max-results=2
javascript:void(0)
http://markantoniou.blogspot.com/search?updated-min=2011-01-01T00:00:00%2B11:00&updated-max=2012-01-01T00:00:00%2B11:00&max-results=4
javascript:void(0)
http://markantoniou.blogspot.com/search?updated-min=2010-01-01T00:00:00%2B11:00&updated-max=2011-01-01T00:00:00%2B11:00&max-results=2
javascript:void(0)
http://markantoniou.blogspot.com/search?updated-min=2009-01-01T00:00:00%2B11:00&updated-max=2010-01-01T00:00:00%2B11:00&max-results=7
javascript:void(0)
http://markantoniou.blogspot.com/search?updated-min=2008-01-01T00:00:00%2B11:00&updated-max=2009-01-01T00:00:00%2B11:00&max-results=11
javascript:void(0)
http://markantoniou.blogspot.com/2008_10_01_archive.html
javascript:void(0)
http://markantoniou.blogspot.com/2008_08_01_archive.html
javascript:void(0)
http://markantoniou.blogspot.com/2008_07_01_archive.html
javascript:void(0)
http://markantoniou.blogspot.com/2008_06_01_archive.html
http://markantoniou.blogspot.com/2008/06/create-conference-posters-from.html
javascript:void(0)
http://markantoniou.blogspot.com/2008_05_01_archive.html
http://pdfmyurl.com
http://pdfmyurl.com

Page 2

regular expressions in Notepad++ useful. After six hours of trial and error, I managed to bend
Notepad++ to my will. And so I decided to post what I think is the most detailed step-by-step guide
to Search and Replace in Notepad++, and certainly the most detailed guide to cleaning up DMDX
.zil output files on the internet.

What's so good about Extended search mode?

One of the major disadvantages of using regular expressions in Notepad++ was that it did not
handle the newline character well—especially in Replace. Now, we can use Extended search mode
to make up for this shortcoming. Together, Extended and Regular Expression search modes give
you the power to search, replace and reorder your text in ways that were not previously possible in
Notepad++.

Search modes in the Find/Replace interface

In the Find (Ctrl+F) and Replace (Ctrl+H) dialogs, the three available search modes are specified in
the bottom right corner. To use a search mode, click on the radio button before clicking the Find
Next or Replace buttons.

Cleaning up a DMDX .zil file

DMDX allows you to run experiments where the user responds by using the mouse or some other
input device. Depending on the number of choices/responses (and of course the kind of task),
DMDX will output a .zil file containing the results (instead of the traditional .azk file). This is

► March (1)

► February (1)

► 2007 (19)

Software Testing
Download

smartbear.com/30-Day-Trial

Easy Automated Tool For Both
Novice And Advanced Testers.
Free Trial.

annoyances (4)

archive (1)

backup (3)

customisation (2)

display (1)

DMDX (2)

download (12)

dropbox (1)

excel (2)

experiments (3)

figures (1)

formatting (3)

Topics

Do you need professional PDFs? Try PDFmyURL!

http://www.slideshare.net/anjesh/the-power-of-regular-expression-use-in-notepad/
http://1.bp.blogspot.com/_RrGIVCQs3RU/SHbq1B0wYlI/AAAAAAAAALI/h21UEYMEivc/s1600-h/np%2B%2Breplace.png
javascript:void(0)
http://markantoniou.blogspot.com/2008_03_01_archive.html
javascript:void(0)
http://markantoniou.blogspot.com/2008_02_01_archive.html
javascript:void(0)
http://markantoniou.blogspot.com/search?updated-min=2007-01-01T00:00:00%2B11:00&updated-max=2008-01-01T00:00:00%2B11:00&max-results=19
http://markantoniou.blogspot.com/search/label/annoyances
http://markantoniou.blogspot.com/search/label/archive
http://markantoniou.blogspot.com/search/label/backup
http://markantoniou.blogspot.com/search/label/customisation
http://markantoniou.blogspot.com/search/label/display
http://markantoniou.blogspot.com/search/label/DMDX
http://markantoniou.blogspot.com/search/label/download
http://markantoniou.blogspot.com/search/label/dropbox
http://markantoniou.blogspot.com/search/label/excel

Page 43

That's my string:

What is the "\1\2" that you said to use as replacement?

The "-" never goes away :-/

March 24, 2011 at 9:35 AM

Mark Antoniou said...

Ok, let's back up a bit. Your original text is this:
Minradio#23-567

You want to keep the numbers, and get rid of whatever is before the numbers as well as
the hyphen. So, in Notepad++ regular expression search mode,

Search for: .*#(.*)-(.*)

Let me break down this search term. The first three characters .*# will search for
anything until a hash # is found (Minradio# in the above example). We don't put
parentheses around this because we don't want to use it in our Replace term; we simply
discard it. The next five characters (.*)- will search for anything until a hyphen - is
found. The parentheses around the period and asterisk mean that that text (which is in
this instance the text immediately after the hash #, that is, the number 23) can be
recalled in our Replace term. The way to recall the contents of this first set of
parentheses is by typing \1. The hyphen is not enclosed within the parentheses and
therefore cannot be recalled in the Replace term; it is simply discarded. Finally, the last
four characters (.*) select the remaining text (in this example 567) and the parentheses
mean that it can be recalled in the Replace term, this time by \2, because it is the
second set of parentheses. So, the Replace term looks like this:

Replace with: \1\2

What you end up with is this:
23567

So, why are you ending up with 23-567? There are a few possiblities:

1. The original text had two hyphens:
Minradio#23--567

Do you need professional PDFs? Try PDFmyURL!

Page 44

If that is the case change your search term to this:
.*#(.*)--(.*)

2. You are including the hyphen within one of the sets of parentheses:
.*#(.*-)(.*)
or
.*#(.*)(-.*)
The hyphen therefore will not be discarded. It will be recalled when you use \1 (top) or \2
(bottom).

3. You are reinserting the hyphen in your Replace term:
Replace with: \1-\2

March 24, 2011 at 11:49 AM

prozaker said...

you could take a look at the pythonscript plugin, it has a python replace method that
everyone could use. It looks complete, textfx or regular n++ regular expression lack
options.

http://sourceforge.net/projects/npppythonscript/
--------
editor.pyreplace('id\=\"A\d+\" ','') # delete all id="A##"
------------

April 1, 2011 at 5:13 AM

el Mauri said...

Hello, nice guide.
I have a (newbie) question:
I have the following list of emails:

[email protected], [email protected], frojasd08_hotmail.com ... and the list so
on

And I want to take with that email that does not comply with the format in a regular
email, in my example:

frojasd08_hotmail.com (it hasn't the character @)

Can you help me with the correct regular express to find this pattern?

Do you need professional PDFs? Try PDFmyURL!

Page 85

Search for: .*[a-z]

Note: there is a newline after the [a-z]

Replace with: nothing - leave blank

And there you go:

Jessie 213
Jack 232
Mark 30

April 6, 2012 at 5:20 AM

Mscarfix said...

Hi Mark: I really appreciate your blog!
Question: I'm working in XML and I want to find all contents between these two tags:
caution tags. (Imagine a left and right carrott tag on each caution with verbiage between
them. For some reason this blog won't allow carrott tags.)
I can find the tags, now how to I copy that content into a separate file? I know I have
about 200 cautions and I want extract only that content to a file. Make sense?

I would appreciate any assistance you can offer, oh "NotePad ++ guru you!

In gratitude,
Mscarfix

April 20, 2012 at 3:16 AM

Mark Antoniou said...

Do you mean greater than and less than signs?

Could you paste a sample of the code (just a few lines).

April 20, 2012 at 3:18 AM

Mark Antoniou said...

So, say that you start off with this

get rid of this.this is the stuff that I want to keep*don't want this
don't need this either.I want to keep this stuff too*the stuff here is crap

Do you need professional PDFs? Try PDFmyURL!

Page 86

Newer Post Older PostHome

Subscribe to: Post Comments (Atom)

1 – 200 of 398 Newer› Newest»Post a Comment

Search for (regular expression): .*\.(.*)\*.*
Replace with: \1

this is the stuff that I want to keep
I want to keep this stuff too

But, I am not sure what your code looks like, i.e., whether it has these tags <>.

Please note that this is the 200th comment (the most that can be shown on a
single Blogger page). Please click the "Next" link below to see newer comments.

April 20, 2012 at 3:38 AM

Ethereal template. Powered by Blogger.

Do you need professional PDFs? Try PDFmyURL!

http://markantoniou.blogspot.com/2008/06/notepad-how-to-use-regular-expressions.html?showComment=1334857113119#c5293070471147256331
http://markantoniou.blogspot.com/2008/06/notepad-how-to-use-regular-expressions.html?commentPage=1
http://markantoniou.blogspot.com/2008/06/notepad-how-to-use-regular-expressions.html?commentPage=1
http://markantoniou.blogspot.com/2008/06/notepad-how-to-use-regular-expressions.html?commentPage=2
http://markantoniou.blogspot.com/2008/06/notepad-how-to-use-regular-expressions.html?commentPage=2
http://www.blogger.com/comment.g?blogID=7580586789577287731&postID=6422280268516169826
http://markantoniou.blogspot.com/2008/07/configure-zotero-to-work-with-google.html
http://markantoniou.blogspot.com/2008/06/create-conference-posters-from.html
http://markantoniou.blogspot.com/
http://markantoniou.blogspot.com/feeds/6422280268516169826/comments/default
http://www.blogger.com
http://pdfmyurl.com
http://pdfmyurl.com

Similer Documents