问题
For my statistics exam, I would like to be able to search for sentences containing specific words in our textbook (we have as a pdf file). I've downloaded the command line tool pdfgrep (grep for pdf files)
An example:
I would like to search for a sentence containing the two words "median" and "exponential"
I've tried:
pdfgrep "\..*median.*exponential\." book-IntroStatistics.pdf
But it does not seem to be working and just gives me large chunks of text.
回答1:
You may use
pdfgrep '[^?\!.]*median[^?\!.]*exponential[^?\!.]*' book-IntroStatistics.pdf
The [^?\!.]*
parts match any 0+ chars other than ?
, !
and .
chars.
来源:https://stackoverflow.com/questions/53558552/using-pdfgrep-to-search-for-sentences-containing-specific-words