How to search for certain strings excluding others

Eric

Beta Tester
Messages
875
Hi,

How do I search, say, the KJV for all instances of the word "for" with a space before it (i.e., " for"), but without a colon before the space? Here's what I tried. I got zero hits using either the RegEx method or the Normal Search with Boolean operators. (Also, here's a verse (1Ch 11:22) in which there is a colon, thus it should not be a hit.) BTW, I only want the word "for", not "form" or others. A "Character String Search" will find me " for" (space + the word "for"), but I don't know how to refine things to get down to what I want. The word "for" is not a rare word in the Bible!

Thank you.

normal_boolean.jpb.JPG
RegEx_Search.jpg
 

Attachments

  • 1Ch11_22.jpg
    1Ch11_22.jpg
    27.9 KB · Views: 225
Normal searches ignore punctuation, so you can't use it there.

A character string search does not support boolean operations like "not."

What you're trying to do is exactly what Regular Expressions are for. It's pretty advanced but you can do almost anything, but what you tried in there is not correct for what you want. I won't make you do homework. Use this for a regex search:

(?<!:) for\b

That says: don't match if the previous character is a colon. Match the text " for" exactly. Make sure we are at a word boundary at the end of the match.

1576242735760.png 1576242777338.png

Regular Expressions are cryptic and hard but amazingly powerful. Here's a site with all kinds of tutorials on RegEx:

 
Last edited:
Thank you very much, Brandon! I often wish I'd learned more about computer programming and all that stuff (i.e., RegEx), but now when I try to learn it, it doesn't stick too well. If that was all I had to do, it might. :)
 
Last edited:
Well, I hope it's OK to ask for Regular Expression help again. I realize you're busy, Brandon, so feel free to take your time or not answer. Or maybe Bill or someone else would know and have time to answer. And it's not totally a SS question, since I plan to use the RE elsewhere, but am trying to see if it'll work in SS first, so I can get to a usable SS user Bible module.

I haven't been able to get my mind around this one, and the link to the RE Tutorial above is good and I tried to find what I needed in it, but I'm over my head.

I'm going to do this RE in NotePad++, but I'm trying it in SS so I can see if I can get the RE to work.

I want to find the markers +sh and -sh and the text which they surround (subheadings I've embedded in my SwordSearcher Commentary which I periodically make into a user Bible module).

+sh/unicode text here with characters such as ąčę ėįš ųūž ĄČĘ ĖĮŠ ŲŪŽ-sh/

Then in NotePad++ I want to delete the markers and the actual text they surround so I can make a pre-Forge file to compile a Bible module without those embedded headings.

Thank you!
 
Last edited:
This is your search string:

\+sh/.*?-sh/

You would just do an empty replacement on that.
 
Thank you so much, Brandon. Works perfectly. I was trying to escape every character, like

Code:
\+\s\h/

Obviously, my approach didn't work.

I appreciate your help a lot!

Eric
 
Last edited:
Back
Top