$ pdfgrep -Pn '(?=.*process)(?=.*preparation)' ~/Str-Cmp.pdf
8:• If a preparation process is used, the method used shall be declared.
10:Standard, preparation may be an important part of the ordering process. See Annex C for some examples of
38:padding. The preparation processing could move the original numerals (in order of occurrence) to the very
$ pdfgrep -A4 -Pn '^(?s:(?=.*process)(?=.*preparation))' ~/Str-Cmp.pdf
8:ISO/IEC 14651:2007(E)
8-• Any specific internal format for intermediate keys used when comparing, nor for the table used. The use of
8- numeric keys is not mandated either.
8-• A context-dependent ordering.
8-• Any particular preparation of character strings prior to comparison.
--
9: ISO/IEC 14651:2007(E)
...
#! /bin/sh
r1= r2=
for a; do
if [ "$r2" ]; then
r1="$r1(?=.*$a)"; r2="$r2|$a"
else
case $a in
--) r2='(?=^--$)';;
*) set -- "$@" "$a";;
esac
fi
shift
done
pdfgrep -A10000 -Pn "(?s:$r1)" "$@" | grep -P --color "$r2"
$ pdfgrepa ~/Str-Cmp.pdf -i -- obtains process preparation
37- the strings after preparation are identical, and the end result (as the user would normally see it) could be
37- collation process applying the same rules. This kind of indeterminacy is undesirable.
37-one obtains after this preparation the following strings:
-P
是的,如果您使用该选项(让它使用PCRE
引擎和类似 perl 的正则表达式),您可以使用零宽度前瞻断言来做到这一点。以上仅在两个单词在同一行时才有效;如果单词可以出现在同一页面的不同行上,则可以执行以下操作:
中的
s
标志(?s:
意味着也.
将匹配换行符。请注意,这只会打印页面的第一行;您可以使用以下-A
选项进行调整:一个粗略的包装脚本,它将以任何顺序从与所有模式匹配的页面中打印与任何模式匹配的行:
usage: pdfgrepa [options] files ... -- patterns ...
$ pdfgrepa ~/Str-Cmp.pdf -i -- obtains process preparation 37- the strings after preparation are identical, and the end result (as the user would normally see it) could be 37- collation process applying the same rules. This kind of indeterminacy is undesirable. 37-one obtains after this preparation the following strings:
https://pdfgrep.org/doc.html