Jump to content

Please read the Forum Rules before posting.

Photo
- - - - -

More REGEX search questions


18 replies to this topic

#1 Starkman

Starkman

    e-Sword Addict

  • Veterans
  • PipPipPipPip
  • 66 posts
  • LocationSouthern Oregon
Offline

Posted 17 January 2019 - 06:43 PM

From the Manual

 

Pg 242 "\bP(\w)+r\b"

 

I tried this with and without parentheses around "\w" and got the same results; why, then, are the paretheses needed? The "+" is going to work against just the "\w" whether it's in paretheses or not.

 

 

 

 

Pg 239

The manual says "(abc){2}” matches the “abc” characters two times.

 

Question: Is this a minimum of two or zero to two times?

 

 

 

 

Also, the manual says “(abc){2,}” matches abc a minimum of two times, and “{,4}” matches “abc” maximally four times.

 

Question: The {,4} is missing in this example, so how should the example read to correcyt itt?

 

 

 

 

My personal searches 

If "\bthe\w" can find words beginning with "the" and extend the search to "therefore", why can't "\bsad\w" find "sadducee" or "sadducees"? I've tried with several versions. It doesn't even find "sad". Further, "sad\w" finds palisaded (Luke 19:43 Darby). Why?

 

Thanks much.

 


There's one, and only one, reason to serve God: because He's God.


#2 Katoog

Katoog

    e-Sword Fanatic

  • Members (T)
  • PipPipPipPipPip
  • 1,285 posts
Online

Posted 18 January 2019 - 05:19 AM

\bP(\w)+r\b
This is every word that begins with a captial P (or afther a - as in Beth-Peor) within the same word boundary and ends with a r.

\bP\w+r\b
This is every word that begins with a captial P (or afther a - as in Beth-Peor) and ends with a r.

Yes, the result is the same because of it is the same word.

"the" and "therefore" are many times in with the big T because they are used as first word.
So try also \bThe

And Sadduccees is with a big S instead of a little s: so try:
Sad
\bSad


Restored Holy Bible 17 and the Restored Textus Receptus

https://rhb.altervis...rg/homepage.htm


#3 Starkman

Starkman

    e-Sword Addict

  • Veterans
  • PipPipPipPip
  • 66 posts
  • LocationSouthern Oregon
Offline

Posted 18 January 2019 - 07:11 AM

Ah, thanks. I interpreted the manual as saying that something like \p would search either caps or regular.

 

Okay, that clears things up a bit. Thanks!


There's one, and only one, reason to serve God: because He's God.


#4 Starkman

Starkman

    e-Sword Addict

  • Veterans
  • PipPipPipPip
  • 66 posts
  • LocationSouthern Oregon
Offline

Posted 18 January 2019 - 10:52 AM

But... I'm still confused about the parentheses around the "\w".  You said, Katoog, that the results are the same whether the parentheses are used because it's the same word. What would be an example, then, using this same format where different results would occur depending on whether the parentheses are used or not? 


There's one, and only one, reason to serve God: because He's God.


#5 JPG

JPG

    Jon.

  • Moderators
  • 1,665 posts
Online

Posted 18 January 2019 - 06:12 PM

The parenthesis in the case shown does not perform anything of use for the search, so it can be omitted.



#6 Starkman

Starkman

    e-Sword Addict

  • Veterans
  • PipPipPipPip
  • 66 posts
  • LocationSouthern Oregon
Offline

Posted 18 January 2019 - 06:23 PM

Okay, so if I want to find the 14th character after subtracting the last non-character, starting with (half way through) the end of the verse, then include the parentheses, right? Right. I'm so on it! (Ha!)

 

Thanks again.


There's one, and only one, reason to serve God: because He's God.


#7 JPG

JPG

    Jon.

  • Moderators
  • 1,665 posts
Online

Posted 18 January 2019 - 06:24 PM

 

Also, the manual says “(abc){2,}” matches abc a minimum of two times, and “{,4}” matches “abc” maximally four times.

 

Question: The {,4} is missing in this example, so how should the example read to correcyt itt?

 

 

 

 

 

 

s{,2} would find a maximum of 2 ss per match in some flavors of regex but in this one you can test that it does not work and will be trying to find literally (without quotes) "s{,2}" it won't interpret the {,2} as a quantifier.

Try s{1,2} and you will get some hits proving this point.



#8 Starkman

Starkman

    e-Sword Addict

  • Veterans
  • PipPipPipPip
  • 66 posts
  • LocationSouthern Oregon
Offline

Posted 18 January 2019 - 06:41 PM

Hmm. It looks like the manual messed up both the comma placement (should be before the "2", not after it) and the reference to "{,4}", which, at least, it got the comma placement correct.


There's one, and only one, reason to serve God: because He's God.


#9 Silverhair

Silverhair

    e-Sword Fanatic

  • Veterans
  • PipPipPipPipPip
  • 331 posts
  • LocationCalgary Alberta
Offline

Posted 18 January 2019 - 11:06 PM

Just went through the Reg Exp. and came across a couple of errors. I think?  Anyone else run across these?

 

Lesson 14: Beginning Verse Anchor “^”

The “^” anchor tells e-Sword to find our search term at the beginning of a verse.

Search for: ^ God

Explanation: Locates all verses starting with the characters “God”.

Verses found: All verses starting with the characters “God”.

Verses not found: Verses with “God” anywhere else in the verse.

Because each e-Sword verse begins with a space, we have a space in “^ God”.

 

After testing this RegEx I found that if you do not put a space between the ^ and the word you are searching for (^Jesus)

you will get all the verses that start with Jesus.

Mat_8:7 Jesus *said to him, "I will come and heal him."

Joh_11:35 Jesus wept.

If you put the space in you get nothing.

 

Lesson 15: Ending Verse Anchor “$”

The “$” anchor tells e-Sword to find our search term at the end of a verse.

Search for: man $

Explanation: Locates all verses ending with the characters “man”.

Verses found: All verses ending with the characters “man”.

Verses not found: Verses with “man” anywhere else in the verse. Will NOT find verses ending in “man.”, “man?”, “man;” etc.

 

Search for: man\W? $

Explanation: Locate all verses ending with the characters “man”, including between zero and one non-word character. “\W” specifies the non word character. “?” quantifies the non-word character to say zero or one non-word characters. Non word characters are all characters other than a-z, A-Z, 0-9, and the underscore _ sign.

Verses found: All verses ending with the characters “man” plus a non-word character. This search locates “man”, “man.”, “man?”, etc.

Verses not found: Verses with “man” anywhere else in the verse.

man$

Luk_23:50 And a man named Joseph, who was a member of the Council, a good and righteous man

 

man\W?$

Exo_28:6 "They shall also make the ephod of gold, of blue and purple and scarlet material and fine twisted linen, the work of the skillful workman.

 

 

Once again I found that if the space is used then you get “0” returns. What works is “man$” and “man\W?$” Has anyone else found this to be so?


Gal 2:20

 

I’m willing to compromise about many things, but not the Word of God 

 

There must be conviction before there can be conversion 

 

 


#10 JPG

JPG

    Jon.

  • Moderators
  • 1,665 posts
Online

Posted 19 January 2019 - 03:03 AM

Some points for all to consider when results are not what we expect.

 

The examples are correct but only if the module has been made as per Rick Meyers spec, which is or was at the time and I quote

 

"The anchors work just fine, but

every entry in the Bible databases begins and ends with a space character,
so anchor accordingly.

15 Oct 2010, 12:28

"

Also there could be punctuation or a Strong's number, and even underlying rtf/html codes  to account for, if we search certain modules.

 

So when using regex, certain conditions need to be accounted for (there could be punctuation or a Strong's number etc if we search certain modules) if the result we get is to be what we actually need, so we the user have to think of all the possibilities that could effect the search hit and code the regex accordingly (not easy).

So

^\W*God\b

and

\bman\W*$

would be a more universal regex that will take account of lack of space, and the addition of punctuation.

 

 

 

Jon





Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users




Similar Topics



Latest Blogs