1

I would like to search for words in a sentence that ends with a question mark - ?

For example I have a pdf document or a word document with the following sentence:

Which of the following describes a benefit of a data lakehouse that is unavailable in a traditional data warehouse?

I would like to search in the document for the word 'lakehouse' that is followed by a question mark.

A successful search would find the above sentence or the following sentence:

Assuming the data engineer is the Delta table owner, which part of the Databricks Lakehouse Platform can the data engineer use to grant the data analysts the appropriate access?

I thought I could do a search like lakehouse?* but that doesn't work.

Any thoughts?

4
  • 3
    I’m voting to close this question because it is about using software. Questions about how to search PDF documents would better fit elsewhere.
    – user55858
    Mar 22, 2023 at 16:15
  • @user52445 Questions about using software for the purpose of writing aee on-topic here. The question is valid.
    – Chenmunka
    Mar 22, 2023 at 18:44
  • 1
    @Chenmunka So questions about regex are on topic just because a writer uses the regex? Makes no sense to me...
    – user55858
    Mar 22, 2023 at 21:54
  • @user52445 was accidently helpful. To the OP, look up regular expressions. Your PDF viewer may or may not have it.
    – Boba Fit
    Mar 23, 2023 at 12:27

2 Answers 2

0

I'm afraid the only way I know how to do this is simply to search for lakehouse, and check if it's in a question or not yourself.

If the questions are formatted in a specific way (such as, the document is a Q&A, and all questions are in bold), there's usually an option to specify format in programs like Word or LibreOffice Writer; not sure about .pdf readers.

1

There's no foolproof way to do this because it's not possible to reliably identify the end of a sentence in English unless you actually read and understand what's being said. The following is either one sentence or two:

  • We saw John Jr. Google the question.

If you ignore this issue (and several others), you can do a search in any editor with a regex search (e.g. Regex101 or Notepad++) using the following regex:

/lakehouse[^.!]*\?/gi

(I'm not sure if all tools support modes, like gi. If it doesn't you may have to lowercase the text to search in to find all the matches.)

Here's what it looks like on Regex101:

the text of the question as the "test string"

8
  • Don't you mean /(\w)\?/ or /(.*) ([^ ]+)\?/? OP is looking for all the last words of all questions, not just "lakehouse".
    – user55858
    Mar 22, 2023 at 22:05
  • @user52445 That's not how I understood the question: "I would like to search in the document for the word 'lakehouse' that is followed by a question mark." (This is amidst two examples that should match where "lakehouse" is not the last word.) The other answer interpreted it the same way as me.
    – Laurel
    Mar 22, 2023 at 22:16
  • 1
    If you continue reading, the question goes on to say: A successful search would find the above sentence or the following sentence: "[...] access?"
    – user55858
    Mar 23, 2023 at 7:42
  • Hi everyone, thanks for reaching out. Sorry for the confusion. As @user52445 pointed out, a successful search would find the above sentence or the following sentence: "[...] access?"
    – Patterson
    Mar 23, 2023 at 9:05
  • Also, "google" is a verb and should be lowercase. I had a hard time making sense of the example sentence, because I took Google to be the last name of John Jr.
    – user55858
    Mar 23, 2023 at 14:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.