Limiting the Display of Search Results--Regular Expressions

Deals with using and making modules and other resources
Post Reply
rcbenjamin
Posts: 13
Joined: Thu Jul 16, 2015 4:13 am

Limiting the Display of Search Results--Regular Expressions

Post by rcbenjamin »

How can I get the search options to display only the verses that has 5 or more words in italics. I am using
<i>\w+</i> to display all italics.

Tim
Site Admin
Posts: 1454
Joined: Sun Dec 07, 2008 1:14 pm

Re: Limiting the Display of Search Results--Regular Expressions

Post by Tim »

Reg Exes are very powerful pattern matching tools, but they can be a little difficult to learn.

Here are some examples in finding italicized words in Bible Analyzer 5:

<i>.+?</i> finds all words in a row from one to infinity.
<i>\w+</i> finds only a single word
<i>\w+(\s\w+){1}</i> finds only a set number of words separated by a space. Here it will find two.
<i>\w+(\s\w+){2}</i> finds three words. (The {2} multiplies only what is in parenthesis, here a space and word string.)

Translate above:
<i> = starting italics tag
.+? = at least one character (? = non-greedy search, so it won't go past the closing tag)
\w+ = at least one word character (a-z)
\s = space character
{2} = multiplier
</i> = closing tag

The above will find italic words together. A little more elaborate method is required to find scattered italicized words.

<i>\w+</i>.+?<i>\w+</i>.+?<i>\w+</i>.+?<i>\w+</i>.+?<i>\w+</i>
or for the multiplier version
<i>\w+</i>(.+?<i>\w+</i>){4}
finds 5 words in a single verse. Note, this reg ex will select or highlight the entire span, not just the italicized words. Reg Exes treat the found string as one unit.

An even shorter alternate method
(<i>\w+</i>)(.+?\1){4}
will not work in Bible Analyzer because of the \1 back reference. (BA uses those internally and putting one in a search causes a conflict)

For more info on Reg Exes, see this page, http://www.regular-expressions.info/reference.html
Tim Morton
Developer, Bible Analyzer

But to him that worketh not, but believeth on him that justifieth the ungodly, his faith is counted for righteousness. (Rom 4:5 AV)

rcbenjamin
Posts: 13
Joined: Thu Jul 16, 2015 4:13 am

Re: Limiting the Display of Search Results--Regular Expressions

Post by rcbenjamin »

Thank you. Why doesn't <i>\w+</i> or any of the expressions you mention find the italics in 1John 2:23 in the AV version

Tim
Site Admin
Posts: 1454
Joined: Sun Dec 07, 2008 1:14 pm

Re: Limiting the Display of Search Results--Regular Expressions

Post by Tim »

<i>.+?</i> finds it.

Those that have only "\w" in them will not because the parenthesis in the verse are not word characters and must be accounted for in the Reg Ex. A dot (.) represents any character.
Tim Morton
Developer, Bible Analyzer

But to him that worketh not, but believeth on him that justifieth the ungodly, his faith is counted for righteousness. (Rom 4:5 AV)

rcbenjamin
Posts: 13
Joined: Thu Jul 16, 2015 4:13 am

Re: Limiting the Display of Search Results--Regular Expressions

Post by rcbenjamin »

<i>.+?</i> does find 1John 2:23 but how can I now combine it with other expressions so that the verse in 1John 2:23 is found with all of the other verses that also have more than 5 words that are in italics?

JPG
Posts: 173
Joined: Fri Feb 27, 2009 4:21 pm

Re: Limiting the Display of Search Results--Regular Expressions

Post by JPG »

This might not be 100% It isn't as easy as it seems to do these type of searches. So the below should get 5 words, 4 plus the one next to the </i>
<i>(?:[^< ]+ ){4,}[^<]+</i>

rcbenjamin
Posts: 13
Joined: Thu Jul 16, 2015 4:13 am

Re: Limiting the Display of Search Results--Regular Expressions

Post by rcbenjamin »

Thanks for your assistance but the expressions need to be modified because in Lev 17:15 it does not mark "of itself" or "himself" in italics. It only marks the phrase "with beasts, whether it be" which is correct but what I wanted was a total count of 5 more words in italics in a single verse regardless of the words being grouped together in a phrase or separated with several spaces, words or punctuations marks between them.

JPG
Posts: 173
Joined: Fri Feb 27, 2009 4:21 pm

Re: Limiting the Display of Search Results--Regular Expressions

Post by JPG »

I think that would need to be done programmatically.

Post Reply