Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Formats > Workshop

Notices

Reply
 
Thread Tools Search this Thread
Old 01-14-2009, 08:52 PM   #1
daesdaemar
Addict
daesdaemar has a spectacular aura aboutdaesdaemar has a spectacular aura aboutdaesdaemar has a spectacular aura aboutdaesdaemar has a spectacular aura aboutdaesdaemar has a spectacular aura aboutdaesdaemar has a spectacular aura aboutdaesdaemar has a spectacular aura aboutdaesdaemar has a spectacular aura aboutdaesdaemar has a spectacular aura aboutdaesdaemar has a spectacular aura aboutdaesdaemar has a spectacular aura about
 
Posts: 210
Karma: 4282
Join Date: Oct 2008
Location: Florida
Device: Sony 505, Kindle 3, iPad 3
Need help with regex expression

I am trying to use find and replace in MS Word to get rid of footnote references in a text file. The references are in the form [n] or [nn] where n represents a numerical digit.

I presume that the bracket symbols, [] must be protected in the regex lingo because everything I try doesn't work.

I have tried both [?] and[*] (wildcards) and they don't work. I would appreciate any help.
daesdaemar is offline   Reply With Quote
Old 01-14-2009, 09:01 PM   #2
Nate the great
Sir Penguin of Edinburgh
Nate the great ought to be getting tired of karma fortunes by now.Nate the great ought to be getting tired of karma fortunes by now.Nate the great ought to be getting tired of karma fortunes by now.Nate the great ought to be getting tired of karma fortunes by now.Nate the great ought to be getting tired of karma fortunes by now.Nate the great ought to be getting tired of karma fortunes by now.Nate the great ought to be getting tired of karma fortunes by now.Nate the great ought to be getting tired of karma fortunes by now.Nate the great ought to be getting tired of karma fortunes by now.Nate the great ought to be getting tired of karma fortunes by now.Nate the great ought to be getting tired of karma fortunes by now.
 
Nate the great's Avatar
 
Posts: 10,607
Karma: 3586209
Join Date: Apr 2007
Location: DC Metro area
Device: Shake a stick plus 1
MSWord uses nonstandard terms for regular expressions.

This one will work: (\[*\])

But I recommend that you use this one: (\[?\]) add more '?' as needed to catch all the desired terms
Nate the great is offline   Reply With Quote
Old 01-14-2009, 09:42 PM   #3
Andybaby
Wizard
Andybaby plays well with othersAndybaby plays well with othersAndybaby plays well with othersAndybaby plays well with othersAndybaby plays well with othersAndybaby plays well with othersAndybaby plays well with othersAndybaby plays well with othersAndybaby plays well with othersAndybaby plays well with othersAndybaby plays well with others
 
Andybaby's Avatar
 
Posts: 1,279
Karma: 2683
Join Date: Nov 2008
Location: New York
Device: PRS-700
nate i assume when you use \ in a regex that means to look for the leading character instead of it being used as part of the formatting? if so i think that makes it so it finally makes sense to me.

I find that Notepad++ works great for removing junk lines in the text.
in notepad++
go to search > find
search for a term that appears in the lines you want to remove.
check mark line, hit find all.
go to search > delete bookmarked lines
Andybaby is offline   Reply With Quote
Old 01-14-2009, 09:46 PM   #4
Nate the great
Sir Penguin of Edinburgh
Nate the great ought to be getting tired of karma fortunes by now.Nate the great ought to be getting tired of karma fortunes by now.Nate the great ought to be getting tired of karma fortunes by now.Nate the great ought to be getting tired of karma fortunes by now.Nate the great ought to be getting tired of karma fortunes by now.Nate the great ought to be getting tired of karma fortunes by now.Nate the great ought to be getting tired of karma fortunes by now.Nate the great ought to be getting tired of karma fortunes by now.Nate the great ought to be getting tired of karma fortunes by now.Nate the great ought to be getting tired of karma fortunes by now.Nate the great ought to be getting tired of karma fortunes by now.
 
Nate the great's Avatar
 
Posts: 10,607
Karma: 3586209
Join Date: Apr 2007
Location: DC Metro area
Device: Shake a stick plus 1
Quote:
Originally Posted by Andybaby View Post
nate i assume when you use \ in a regex that means to look for the leading character instead of it being used as part of the formatting? if so i think that makes it so it finally makes sense to me.

I find that Notepad++ works great for removing junk lines in the text.
in notepad++
go to search > find
search for a term that appears in the lines you want to remove.
check mark line, hit find all.
go to search > delete bookmarked lines

The characters [] have a special meaning in regular expressions. A slash '\' is placed before each one to force the use of the non-special meaning.

Anyway, I tested the expressions I provided above. They work correctly in MSWord.
Nate the great is offline   Reply With Quote
Old 01-14-2009, 10:02 PM   #5
Andybaby
Wizard
Andybaby plays well with othersAndybaby plays well with othersAndybaby plays well with othersAndybaby plays well with othersAndybaby plays well with othersAndybaby plays well with othersAndybaby plays well with othersAndybaby plays well with othersAndybaby plays well with othersAndybaby plays well with othersAndybaby plays well with others
 
Andybaby's Avatar
 
Posts: 1,279
Karma: 2683
Join Date: Nov 2008
Location: New York
Device: PRS-700
Quote:
Originally Posted by Nate the great View Post
The characters [] have a special meaning in regular expressions. A slash '\' is placed before each one to force the use of the non-special meaning.
thank you, they finally make sense to me.
Andybaby is offline   Reply With Quote
Old 01-14-2009, 10:03 PM   #6
Patricia
Reader
Patricia ought to be getting tired of karma fortunes by now.Patricia ought to be getting tired of karma fortunes by now.Patricia ought to be getting tired of karma fortunes by now.Patricia ought to be getting tired of karma fortunes by now.Patricia ought to be getting tired of karma fortunes by now.Patricia ought to be getting tired of karma fortunes by now.Patricia ought to be getting tired of karma fortunes by now.Patricia ought to be getting tired of karma fortunes by now.Patricia ought to be getting tired of karma fortunes by now.Patricia ought to be getting tired of karma fortunes by now.Patricia ought to be getting tired of karma fortunes by now.
 
Patricia's Avatar
 
Posts: 11,509
Karma: 2199070
Join Date: May 2007
Location: South Wales, UK
Device: Sony PRS-500, PRS-505, Asus EEEpc 4G
It sometimes is worth looking to see whether the footnotes are in a particular style. If so, you can search and delete the instances of the style.
Patricia is offline   Reply With Quote
Old 01-15-2009, 05:04 AM   #7
Jellby
frumious Bandersnatch
Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.Jellby ought to be getting tired of karma fortunes by now.
 
Jellby's Avatar
 
Posts: 6,316
Karma: 4963983
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
In vim it could be: \[\d\+\]

\[, \]: literal [ and ]
\d: a digit
\+: repeated one or more times.
Jellby is online now   Reply With Quote
Old 01-15-2009, 12:46 PM   #8
daesdaemar
Addict
daesdaemar has a spectacular aura aboutdaesdaemar has a spectacular aura aboutdaesdaemar has a spectacular aura aboutdaesdaemar has a spectacular aura aboutdaesdaemar has a spectacular aura aboutdaesdaemar has a spectacular aura aboutdaesdaemar has a spectacular aura aboutdaesdaemar has a spectacular aura aboutdaesdaemar has a spectacular aura aboutdaesdaemar has a spectacular aura aboutdaesdaemar has a spectacular aura about
 
Posts: 210
Karma: 4282
Join Date: Oct 2008
Location: Florida
Device: Sony 505, Kindle 3, iPad 3
Quote:
Originally Posted by Nate the great View Post
MSWord uses nonstandard terms for regular expressions.

This one will work: (\[*\])

But I recommend that you use this one: (\[?\]) add more '?' as needed to catch all the desired terms
Thanks for the reply, Nate. Works great.
daesdaemar is offline   Reply With Quote
Old 01-15-2009, 07:29 PM   #9
delphidb96
Wizard
delphidb96 ought to be getting tired of karma fortunes by now.delphidb96 ought to be getting tired of karma fortunes by now.delphidb96 ought to be getting tired of karma fortunes by now.delphidb96 ought to be getting tired of karma fortunes by now.delphidb96 ought to be getting tired of karma fortunes by now.delphidb96 ought to be getting tired of karma fortunes by now.delphidb96 ought to be getting tired of karma fortunes by now.delphidb96 ought to be getting tired of karma fortunes by now.delphidb96 ought to be getting tired of karma fortunes by now.delphidb96 ought to be getting tired of karma fortunes by now.delphidb96 ought to be getting tired of karma fortunes by now.
 
Posts: 3,000
Karma: 300001
Join Date: Jan 2007
Location: Citrus Heights, California
Device: TWO Kindle 2s, one each Bookeen Cybook Gen3, Sony PRS-500, Axim X51V
Sooo.... Does anyone understand how to get Word to replace the string 'p. ###', where ### can be anything from 1 to 999, with a space? Without having to do a separate find/replace on 3-digit, then 2-digit, then 1-digit numeric strings?

Derek
delphidb96 is offline   Reply With Quote
Old 01-15-2009, 07:36 PM   #10
Nate the great
Sir Penguin of Edinburgh
Nate the great ought to be getting tired of karma fortunes by now.Nate the great ought to be getting tired of karma fortunes by now.Nate the great ought to be getting tired of karma fortunes by now.Nate the great ought to be getting tired of karma fortunes by now.Nate the great ought to be getting tired of karma fortunes by now.Nate the great ought to be getting tired of karma fortunes by now.Nate the great ought to be getting tired of karma fortunes by now.Nate the great ought to be getting tired of karma fortunes by now.Nate the great ought to be getting tired of karma fortunes by now.Nate the great ought to be getting tired of karma fortunes by now.Nate the great ought to be getting tired of karma fortunes by now.
 
Nate the great's Avatar
 
Posts: 10,607
Karma: 3586209
Join Date: Apr 2007
Location: DC Metro area
Device: Shake a stick plus 1
Quote:
Originally Posted by delphidb96 View Post
Sooo.... Does anyone understand how to get Word to replace the string 'p. ###', where ### can be anything from 1 to 999, with a space? Without having to do a separate find/replace on 3-digit, then 2-digit, then 1-digit numeric strings?

Derek
Look for this:

(p. [0-9]{1,3})
Nate the great is offline   Reply With Quote
Old 01-15-2009, 07:42 PM   #11
delphidb96
Wizard
delphidb96 ought to be getting tired of karma fortunes by now.delphidb96 ought to be getting tired of karma fortunes by now.delphidb96 ought to be getting tired of karma fortunes by now.delphidb96 ought to be getting tired of karma fortunes by now.delphidb96 ought to be getting tired of karma fortunes by now.delphidb96 ought to be getting tired of karma fortunes by now.delphidb96 ought to be getting tired of karma fortunes by now.delphidb96 ought to be getting tired of karma fortunes by now.delphidb96 ought to be getting tired of karma fortunes by now.delphidb96 ought to be getting tired of karma fortunes by now.delphidb96 ought to be getting tired of karma fortunes by now.
 
Posts: 3,000
Karma: 300001
Join Date: Jan 2007
Location: Citrus Heights, California
Device: TWO Kindle 2s, one each Bookeen Cybook Gen3, Sony PRS-500, Axim X51V
Nate,

Thanks!

Derek
delphidb96 is offline   Reply With Quote
Old 01-18-2009, 02:44 PM   #12
daesdaemar
Addict
daesdaemar has a spectacular aura aboutdaesdaemar has a spectacular aura aboutdaesdaemar has a spectacular aura aboutdaesdaemar has a spectacular aura aboutdaesdaemar has a spectacular aura aboutdaesdaemar has a spectacular aura aboutdaesdaemar has a spectacular aura aboutdaesdaemar has a spectacular aura aboutdaesdaemar has a spectacular aura aboutdaesdaemar has a spectacular aura aboutdaesdaemar has a spectacular aura about
 
Posts: 210
Karma: 4282
Join Date: Oct 2008
Location: Florida
Device: Sony 505, Kindle 3, iPad 3
Nate,

You're a wonder at these expressions. Do you have any suggestions for where I might teach myself this stuff? I use primarily Word for my editing.
daesdaemar is offline   Reply With Quote
Old 01-18-2009, 03:53 PM   #13
mtravellerh
book creator
mtravellerh ought to be getting tired of karma fortunes by now.mtravellerh ought to be getting tired of karma fortunes by now.mtravellerh ought to be getting tired of karma fortunes by now.mtravellerh ought to be getting tired of karma fortunes by now.mtravellerh ought to be getting tired of karma fortunes by now.mtravellerh ought to be getting tired of karma fortunes by now.mtravellerh ought to be getting tired of karma fortunes by now.mtravellerh ought to be getting tired of karma fortunes by now.mtravellerh ought to be getting tired of karma fortunes by now.mtravellerh ought to be getting tired of karma fortunes by now.mtravellerh ought to be getting tired of karma fortunes by now.
 
mtravellerh's Avatar
 
Posts: 9,626
Karma: 1723914
Join Date: Oct 2008
Location: Luxembourg
Device: PB360°
Quote:
Originally Posted by Jellby View Post
In vim it could be: \[\d\+\]

\[, \]: literal [ and ]
\d: a digit
\+: repeated one or more times.
\d+ is also working (for pagenumbers, for example)

Andy's way also works fine and is fast but can lead to errors (overkill) if you're not conscientious. You really have to be sure that there is nothing else on that line you're looking for ever!

Last edited by mtravellerh; 01-18-2009 at 03:57 PM.
mtravellerh is offline   Reply With Quote
Old 01-18-2009, 04:27 PM   #14
=X=
Wizard
=X= ought to be getting tired of karma fortunes by now.=X= ought to be getting tired of karma fortunes by now.=X= ought to be getting tired of karma fortunes by now.=X= ought to be getting tired of karma fortunes by now.=X= ought to be getting tired of karma fortunes by now.=X= ought to be getting tired of karma fortunes by now.=X= ought to be getting tired of karma fortunes by now.=X= ought to be getting tired of karma fortunes by now.=X= ought to be getting tired of karma fortunes by now.=X= ought to be getting tired of karma fortunes by now.=X= ought to be getting tired of karma fortunes by now.
 
=X='s Avatar
 
Posts: 3,672
Karma: 12205348
Join Date: Mar 2008
Device: Galaxy S, Nook w/CM7
Quote:
Originally Posted by daesdaemar View Post
Do you have any suggestions for where I might teach myself this stuff? I use primarily Word for my editing.
Okay I'm not Nate so parding me for intruding, now to answer your question


MS Word does not use standard regular notation and in addition it's implementation is inferior to true RegEx. But it is still powerful and conceptually still make use of the regular expression concepts

I'd recommend reading http://www.regular-expressions.info/

These two articles are pretty good. They got me started when I decided to write the BookCreator tool
http://office.microsoft.com/en-us/he...873041033.aspx
http://office.microsoft.com/en-us/he...873051033.aspx


Also there are scores of Perl and Javascript tutorials that use regular expressions. The syntax will be a little different but they still try to solve the same problems and you will learn from the exercise of converting the syntax.

Reglar expressions have a steep learning curve but once your over the first hump, you'll realize its the best invention since coffee. ... Yea I know the saying is sliced bread but give me coffee and regluar expressions --hmmmm I'm in heaven.

=X=
=X= is offline   Reply With Quote
Old 01-19-2009, 05:29 AM   #15
HarryT
eBook Enthusiast
HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.HarryT ought to be getting tired of karma fortunes by now.
 
HarryT's Avatar
 
Posts: 65,484
Karma: 43935573
Join Date: Nov 2006
Location: UK
Device: Kindle Voyage, iPad Mini, iPhone 4, MS Surface Pro, N7
Quote:
Originally Posted by Nate the great View Post
MSWord uses nonstandard terms for regular expressions.

This one will work: (\[*\])

But I recommend that you use this one: (\[?\]) add more '?' as needed to catch all the desired terms
If, as stated, the footnote reference is numeric, then:

\[[0-9]*\]

is safer in that it will only catch numeric references.
HarryT is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular Expression Help Azhad Calibre 86 09-27-2011 03:37 PM
Regular Expression Help smartmart Calibre 5 10-17-2010 06:19 AM
Need Help Creating a Regular Expression Worm Calibre 9 08-18-2010 02:20 PM
Help with the regular expression Dysonco Calibre 9 03-22-2010 11:45 PM
help with regex expression daesdaemar Workshop 4 02-19-2010 08:38 AM


All times are GMT -4. The time now is 10:55 AM.


MobileRead.com is a privately owned, operated and funded community.