Power Tip: Using variables to Search and Replace in Word

Page 1 of 3 (45 items) 1 2 3 Next >
This post has 44 Replies | 5 Followers

Posts 1403
Forum MVP
Fr Devin Roza | Forum Activity | Posted: Mon, Jun 18 2012 9:53 AM

I created a Personal Book from a class I took this semester on the Acts of the Apostles. The professor's class notes used the European format for citing the Bible, where it is common to say Acts 1,1 instead of Acts 1:1.

Given that Logos Personal Books don't understand this format, I found myself with the difficulty of trying to replace all the commas with semicolons. Luckily with Microsoft Word this is extremely easy.

I told Microsoft Word to search for every occurrence of "a number followed by a comma followed by a number" and replace it with the same numbers, but with a semicolon in between.

Here is what the search looks like. Notice that the "Use Wildcards" option is selected.

There is documentation on doing this type of search and replace here: http://office.microsoft.com/en-us/word-help/find-and-replace-text-by-using-regular-expressions-advanced-HA102350661.aspx

This technique can also be used to insert the codes which Personal Books need to indicate that a certain heading is, for example, a Dictionary Head Word. If all the head words in your dictionary have the same formatting, in just a matter of a few minutes of work you could apply the information that the Logos Personal Book needs to recognize 1000s of head words.

Posts 1389
Robert M. Warren | Forum Activity | Replied: Mon, Jun 18 2012 10:42 AM

Thanks for sharing this. I had not seen that type of citation style before, so now i'll be keeping an eye out for it.

Using the variables is also handy for bible milestones. The key, as you have indicated, is consistent formatting.

Win7 Android 4.4.2

Posts 8820
fgh | Forum Activity | Replied: Mon, Jun 18 2012 10:57 AM

Fr Devin Roza:
the European format

Please don't call it "the European format". It's as foreign to me as it is to Americans, if not more.

Fr Devin Roza:
I found myself with the difficulty of trying to replace all the commas with semicolons.

You mean 'colons', not 'semicolons', but beside that:

Personally, I would definitely prefer if people who prepare PB files for sharing didn't do that. It makes them useless for academic purposes, where quotes have to be exact. (What people do with their private PB files is, of course, up to them.)

Another problem may be that complicated references may end up distorted if one doesn't check very carefully beforehand how the author has chosen to write such.

The better method is to use search and replace to create a tag looking like [[Acts 1,1 >> Acts 1:1]].

"The Christian way of life isn't so much an assignment to be performed, as a gift to be received."  Wilfrid Stinissen

Mac Pro OS 10.9.

Posts 1403
Forum MVP
Fr Devin Roza | Forum Activity | Replied: Tue, Jun 19 2012 2:53 AM

fgh:

Fr Devin Roza:
the European format

Please don't call it "the European format". It's as foreign to me as it is to Americans, if not more.

Didn't mean to offend. I've studied theology and Scripture in Europe for 4 years in 2 different universities and have seen this format used very often, almost exclusively in fact. I've never seen it in stuff from the US, however. It seems to be especially common in writings from Romance Languages, although I've seen it used in English writings as well (as in this case). It could be that it's something typical of the Romance Languages more than Europe per se, and which at times makes it into English documents due to the Romance Languages being so present here in Europe.

fgh:

The better method is to use search and replace to create a tag looking like [[Acts 1,1 >> Acts 1:1]].

If you know a quick way to do this please share. It becomes especially complicated when you get one citation after another, something which the simple solution I proposed handles perfectly (as "complicated references" get a space after the comma when it is not a Scriptural citation). In my case, for example, I replaced 1700 Scriptural citations with a format that Logos understands in a matter of minutes (most of the time being spent going through manually about 50 find and replaces to make sure I wasn't getting false positives), making the document extremely useful within Logos without spending much time. Perfect for many, many scenarios.

BTW, the point of this post was more to share a method to quickly do intelligent search and replace in Word than to propose that this is something valid for every document and every case. As you pointed out, there are times in which this particular search would not be useful. But the goal is to open up peoples eyes so that they can apply the principles here in the scenarios that they encounter.

If you or others want to share more examples of how you would do so in more complicated scenarios I'm sure it could be very helpful.

Posts 1403
Forum MVP
Fr Devin Roza | Forum Activity | Replied: Tue, Jun 19 2012 3:31 AM

I was curious about the formatting question in Europe, so I investigated a little bit. Here's what I found.

From what I've been able to discover, in German, French, Italian, Spanish, and Portuguese the typical citation format is Acts 1,1 with a comma, not a colon.

In English of course the colon prevails. Even so, there are certain references to the comma being used instead of the colon as a possibility in English, especially in Europe. BTW, in Dutch it seems that the colon is also standard.

Not really the topic of this thread, but nevertheless something that Logos might want to look into adapting for, especially if they get more into the mainland European languages.

Posts 8482
Forum MVP
NB.Mick | Forum Activity | Replied: Wed, Jun 20 2012 12:22 PM

Thanks for sharing this - I'm a long-time user of word, but wasn't aware of the ability to use regular expressions in searches.

Fr Devin Roza:
From what I've been able to discover, in German, French, Italian, Spanish, and Portuguese the typical citation format is Acts 1,1 with a comma, not a colon

Judging from other threads, you may add Czech to your list of languages that use the European notation.

Fr Devin Roza:
something that Logos might want to look into adapting for, especially if they get more into the mainland European languages.

The Logos PB builder supports autodetection of bible references in European notation in some languages (e.g. Czech), but not all.

Running Logos 7 latest (beta) version

Posts 1403
Forum MVP
Fr Devin Roza | Forum Activity | Replied: Thu, Jun 21 2012 12:30 AM

NB.Mick:

The Logos PB builder supports autodetection of bible references in European notation in some languages (e.g. Czech), but not all.

That's great news. What do you need to do to force this type of detection in the PB Builder? Change the language of the document in Word to Czech and turn auto-detection of the language off?

Posts 1389
Robert M. Warren | Forum Activity | Replied: Thu, Jun 21 2012 8:47 AM

NB.Mick:
The Logos PB builder supports autodetection of bible references in European notation in some languages

I was also happy to discover that the PB compiler also automatically detects citations using Roman numerals, (e.g. John iii. 16), which I find in Owen's work. Maybe it's a Puritan thing, but I have also seen it as late as the late 1950s in a work by J.I. Packer.

Win7 Android 4.4.2

Posts 1403
Forum MVP
Fr Devin Roza | Forum Activity | Replied: Thu, Jun 21 2012 9:19 AM

NB.Mick:

The Logos PB builder supports autodetection of bible references in European notation in some languages (e.g. Czech), but not all.

I ran a few tests, but was not able to make this work. I tried to import English documents with the Acts 1,1 format as if they were Spanish, or Czech, etc (the text still being in English). Logos either did not recognize the references at all, or recognized them wrong (i.e. Acts 1,1 Logos understands as Acts 1).

I then created a brief document in Spanish with "Hechos 1,1" and a few other similar citations, and imported it into Logos PBB, setting the language in PBB to Spanish. Same problem, Logos was expecting the "Hechos 1:1" format.

Posts 8482
Forum MVP
NB.Mick | Forum Activity | Replied: Fri, Jun 22 2012 5:40 AM

Fr Devin Roza:

NB.Mick:

The Logos PB builder supports autodetection of bible references in European notation in some languages (e.g. Czech), but not all.

I ran a few tests, but was not able to make this work.

Devin,

according to my tests, the PB compiler just looks at the document language you give when you complie the document and disregards the Word settings.

I'm not on my Logos computer right now to show you with screenshots, but you may have a look in the following thread: http://community.logos.com/forums/p/48257/357856.aspx#357856 - I linked to the post that shows Czech references

Hope this helps,

Mick

Running Logos 7 latest (beta) version

Posts 1403
Forum MVP
Fr Devin Roza | Forum Activity | Replied: Fri, Jun 22 2012 6:28 AM

Thanks Mick. Looks good for Czech. I created a feature request about this problem in other languages for Logos here: http://logos.uservoice.com/forums/42823-logos-bible-software-4/suggestions/2947047-support-scripture-reference-formats-from-personal-

Posts 3456
BillS | Forum Activity | Replied: Fri, Jun 22 2012 10:42 AM

Fr Devin Roza:
This technique can also be used

Thanks so much! I adapted the technique to remove trailing spaces after superscript verse numbers. Works great!

I'd wondered how to use wild cards... your post led me to try them, & it's powerful! 

Thanks again!

Cool Geeked

The Grace & Peace of our Lord Jesus Christ be with you!
Bill

W8.1 64bit, Office 2016
i7, 2.40GHz, 1Gb graphics, 16Gb RAM, 512Gb Samsung 850 Pro SSD
Samsung Galaxy S7, Android 7.0

Posts 1403
Forum MVP
Fr Devin Roza | Forum Activity | Replied: Sat, Jun 23 2012 8:09 AM

Glad it could be of use. If you have a moment, post a screenshot of your search and replace window.

I think it would probably be helpful if we can get together a bunch of examples.

Posts 3456
BillS | Forum Activity | Replied: Sat, Jun 23 2012 10:37 AM

Fr Devin Roza:
post a screenshot of your search and replace window

To remove the trailing space, I added a space at end of the "Find What" term. The "Replace With" term has no trailing space. Problem solved, so long as Logos keeps putting a superscript space after the superscript number. And since I don't care whether the number is single or double digit (this Find What only finds the least significant digit), it works slick.

The Grace & Peace of our Lord Jesus Christ be with you!
Bill

W8.1 64bit, Office 2016
i7, 2.40GHz, 1Gb graphics, 16Gb RAM, 512Gb Samsung 850 Pro SSD
Samsung Galaxy S7, Android 7.0

Posts 74
Stephen | Forum Activity | Replied: Sat, Jun 23 2012 3:28 PM

Dear Sir

I'm new to preparing PPB, I would like more information about preparing the proper terms, have you further adice on the subject.

Also, why does my Hebrew Text not appear in my commentary I'm making, there's space and if one clicks on it, it appears in a narrow box on the right?

(1-9) /1 What's this really mean in plain English...Thanks for your ideas and any help you msy be able to render

Stephen

Posts 3578
steve clark | Forum Activity | Replied: Sat, Jun 23 2012 4:18 PM

Hi Stephen,

i am not the one you were addressing, but this might possibly be helpful for you.

Stephen Chaffer:
I'm new to preparing PPB, I would like more information about preparing the proper terms, have you further adice on the subject.

A. Read the Personal Book wiki page for details on using PBs.

B. Get the PB macros for Word.

C. If you don't understand a particular feature, then start a new post here on the forum and ask your question. Give as much details as possible so others can help.

 

Stephen Chaffer:
Also, why does my Hebrew Text not appear in my commentary I'm making

You might start by copying Hebrew text from Logos4 and pasting it into your Word docx file. If you are familiar with typing Hebrew directly into Word, then make sure you are using the same font that is used in Logos4.
[Below in the image you can see that my PB has Hebrew entered into it. Layered above my PB is Word where i show the font selection box that Word provides, relative to text that i have pasted from L4 into Word.]

(Click on the above picture to have your browser enlarge the picture)

 

QLinks, Bibl2, LLR, Macros
Dell Insp 17-5748, i5, 1.7 GHz, 8G RAM, win 8.1

Posts 1403
Forum MVP
Fr Devin Roza | Forum Activity | Replied: Sun, Jun 24 2012 1:09 AM

Stephen Chaffer:

(1-9) /1 What's this really mean in plain English...Thanks for your ideas and any help you msy be able to render

[0-9] indicates that Word should look for any single number, anywhere from 0-9. As there is a space following the [0-9], Word will also look for a space. Also notice that the "Superscript" format is being searched for.

The \1 refers to the first Wildcard search it did above (in this case "[0-9]" without the space).

What Word will do with this search is look for Superscript formatted text that consists of any number plus a space. It will then replace it with that same number without the space.

What's special about this search is that it will replace "1 " with "1", "2 " with "2 ", etc., all with just one search.

In my search it is just slightly more complicated. It is looking for any number followed by a comma and then followed by any number. It will replace it with the same two numbers but with a colon inbetween instead of the comma. In my case the replace string is "\1:\2". \1 refers to the first number, \2 to the second, and so on. Notice that this 1 search and replace that I did would otherwise have required 100 different search and replaces had I not used variables.

Again, more documentation and examples are here: http://office.microsoft.com/en-us/word-help/find-and-replace-text-by-using-regular-expressions-advanced-HA102350661.aspx

Posts 15805
Forum MVP
Keep Smiling 4 Jesus :) | Forum Activity | Replied: Sun, Jun 24 2012 1:44 AM

Stephen Chaffer:
(1-9) /1 What's this really mean in plain English

The search syntax:

([0-9]),([0-9])

looks for one number [0-9] that is followed by a comma, which is followed by one number [0-9]

Note: [0-9] looks for a range of characters from 0 through 9, which is equivalent to specifying all numeric digits [0123456789].

The reference  /1 refers to what was found inside the first set of parenthesis while /2 refers to the second set of parenthesis so the chapter and verse numbers can be different.

While formatting New Testament in a personal book Bible => American Standard Version 1901 - Personal Bible without Chapter and Verse #'s decided to add chapter milestones so wanted tag for the first verse in a chapter

{{bible-on}}[[@BibleKJV:Mt28:1]]

to be preceded by a chapter milestone and a space:

[[@BibleKJV:Mt28]] {{bible-on}}[[@BibleKJV:Mt28:1]]

Should have used wildcard search string:

(??bible-on[\}]{2})(??[\@]BibleKJV:[0-9,A-Z]{1,2}[a-z]{1,2}[0-9]{1,3})(:1)([\]]{2})

with replacement

\2\4 \1\2\3\4

The second set of parenthesis (??[\@]BibleKJV:[0-9,A-Z]{1,2}[a-z]{1,2}[0-9]{1,3}) searches for:

  • ??  => two wildcard characters that can find [[ since Microsoft Word 2010 has a recursion limit for correctly parsing regular expressions with escaped characters (milestones are enclosed in brackets)
  • [\@]  => escaped syntax to search for @ special character (begins milestone tag)
  • BibleKJV:  => specific string of characters (Bible milestone using KJV versification)
  • [0-9,A-Z]{1,2} => one or two character(s): number OR capital letter (initial capital letter of Book plus a leading number)
  • [a-z]{1,2}  => one or two lower case letters (rest of Book abbreviation in lower case)
  • [0-9]{1,3}  => one, two, or three numbers (chapter number)

The fourth set of parenthesis ([\]]{2}) searches for:

  • [\]]{2}  => escaped syntax to search for two ]] closing brackets (milestones are enclosed in brackets)

The replacement string /2/4 /1/2/3/4 specifies that the second and fourth set of search results should be followed by a space then the original search results (copy the Bible milestone for verse 1 in a chapter to become the chapter milestone, which does not have a verse number).

For milestone tagging, personally used two or three character abbreviations for books with initial capital => http://www.logos.com/L4/support/biblebookabbrev

Note: thread => American Standard Version 1901 - Personal Bible without Chapter and Verse #'s now has an updated New Testament file because my initial search string missed book abbreviations that began with a number.

Keep Smiling Smile

Posts 74
Stephen | Forum Activity | Replied: Sun, Jun 24 2012 10:18 AM

Hi 

Thanks for your help, I knew these were possible but didn't know how it ticked.

Also, your explanation is very helpful, and you've made it easy to follow

Thanks again!

Stephen

Posts 8820
fgh | Forum Activity | Replied: Wed, Jun 27 2012 11:06 AM

Fr Devin Roza:

fgh:

Please don't call it "the European format". It's as foreign to me as it is to Americans, if not more.

Didn't mean to offend.

I know. I'm just a bit sensitive to Europe being treated as if it was one nation. It isn't. After all, we've spent most of history at each others' throats. There are vast cultural differences even between Sweden and Norway, or Sweden and Finland.

Fr Devin Roza:
It could be that it's something typical of the Romance Languages more than Europe per se

My guess, from the languages you've mentioned and my own experience of which [British] English books I've found it in, would be that it's originally a Catholic thing. I don't think I've ever seen it in Swedish.

Fr Devin Roza:
If you know a quick way to do this please share.

I use LibreOffice, not Word, and I do it so seldom that I have to look it up each time, so I'm afraid I can't. It's easy enough once you've got the strings right, though.

Fr Devin Roza:
something which the simple solution I proposed handles perfectly (as "complicated references" get a space after the comma when it is not a Scriptural citation)

With "complicated" I was more referring to something like "8:4-6,11,14; 17; 21:12f,16; 23". Before you replace commas with colons you have to make sure that the book doesn't already use colons for something else, or you'll end up with a string where you can no longer figure out what's supposed to be a verse and what's supposed to be a chapter.

 

"The Christian way of life isn't so much an assignment to be performed, as a gift to be received."  Wilfrid Stinissen

Mac Pro OS 10.9.

Page 1 of 3 (45 items) 1 2 3 Next > | RSS
Copyright 1992-2015 Faithlife / Logos Bible Software.