App-Greple
view release on metacpan or search on metacpan
greple -pi -e 'cyclic redundancy c\w+' rfc*
greple -o --joinby=' ' -ie 'cyclic redundancy c\w+' rfc*
### find Kanji and not CJKUnifiedIdeographs / æ¼¢åã ãã© CJKUnifiedIdeographs ãããªãæåãæ¢ã
greple --inside='\p{Han}+' '[^\s\p{InCJKUnifiedIdeographs}]'
# This works, but quite slow. Not recommended.
# åããã©ãã§ã¼é
ããããããªãã¨ãã¡ãé§ç®ãã
### guess data encoding / æåã³ã¼ããèªåå¤å®ãã
greple --icode=guess
### specify data encoding / æåã³ã¼ããæå®ãã
greple --icode=euc-jp
greple --icode=shif-jis
### specify guessing code set / èªåå¤å®ããã³ã¼ããæå®ãã
greple --icode=utf8,euc-jp,shift-jis,7bit-jis
### add to guessing code set / èªåå¤å®ããã³ã¼ãã追å ãã
greple --icode=+euc-kr
---
## Filter / ãã£ã«ã¿ã¼
### expand tabs before seach / ã¿ããå±éãã¦ããæ¤ç´¢ãã
greple -n --if=expand
**-e**/**-v** (["PATTERNS"](#patterns))
## CHARACTER CODE
- **--icode**=_code_
Target file is assumed to be encoded in utf8 by default. Use this
option to set specific encoding. When handling Japanese text, you may
choose from 7bit-jis (jis), euc-jp or shiftjis (sjis). Multiple code
can be supplied using multiple option or combined code names with
space or comma, then file encoding is guessed from those code sets.
Use encoding name `guess` for automatic recognition from default code
list which is euc-jp and 7bit-jis. Following commands are all
equivalent.
greple --icode=guess ...
greple --icode=euc-jp,7bit-jis ...
greple --icode=euc-jp --icode=7bit-jis ...
Default code set are always included suspect code list. If you have
just one code adding to suspect list, put + mark before the code name.
Next example does automatic code detection from euc-kr, ascii, utf8
and UTF-16/32.
greple --icode=+euc-kr ...
RIPGREP-STUDY.md view on Meta::CPAN
4. 渡ããªãå ´å㯠`rg --files`ï¼ãã¡ã¤ã«åæã®ã¿ï¼ã«ãã©ã¼ã«ãã㯠â ããã§ã
.gitignore å°éã»ãã¤ããªã¹ãããã®æ©æµã¯ãã
**æ£ããã®æ¡ä»¶**: ããªãã£ã«ã¿ã¯ãgreple ãããããããã¡ã¤ã«ã®ä¸ä½éåããè¿ãå¿
è¦ãããã
注æç¹ã¨å¯¾ç:
| æ¸å¿µ | 対ç |
|---|---|
| æ£è¦è¡¨ç¾æ¹è¨å·®ï¼å¾èªã¿çï¼ | `-P` (PCRE2) ã使ãã夿ä¸è½ãªãç´ éããã©ã¼ã«ãã㯠|
| è¡è·¨ããã¿ã¼ã³ | `rg -U`ï¼ãã«ãã©ã¤ã³ï¼ãä»ãã |
| é UTF-8 ãã¡ã¤ã«ï¼--icodeï¼ | `rg -E <encoding>` ã«ãããã³ã°ãguess æã¯ç´ éã |
| `--if` ãã£ã«ã¿å¯¾è±¡ï¼zip çï¼ | rg ã§ã¯å¤å®ä¸è½ â ç´ éãï¼å¾æ¥ã©ãã greple ãå¦çï¼ |
| 大æåå°æå (`-i`) | `rg -i` ãé£å |
| must/need ã®è¤æ°ãã¿ã¼ã³ | å齿§ãã¿ã¼ã³ã® OR ã§ `-e` ã並ã¹ãã°ä¸ä½éåã«ãªã |
å®å
¨å´ã«åãï¼è¿·ã£ããç´ éãï¼è¨è¨ãªãçµæã®æ£ããã¯ä¿ãããæ§è½ã ããæ®µéçã«åä¸ããã
**广**: ããããçãªå¤§è¦æ¨¡ããªã¼ã§æ¯é
çãªããããããªããã¡ã¤ã«ã®å¦çãã rg ã®é度
ï¼ä¸¦åèµ°æ» + .gitignore/ãã¤ããªã¹ãããï¼ã§æ¶ããã宿¸¬ 3000 ãã¡ã¤ã«ã§ 5 åã
å®ããã¸ã§ã¯ãã®å·¨å¤§ããªã¼ã§ã¯æ¡éãã«ãªããgreple ã®ä¸»ç¨éï¼ããã¥ã¡ã³ãã»ã³ã¼ãæ¤ç´¢ï¼ã§
æã使ã大ããã®ã¯ãã®ã±ã¼ã¹ã
script/greple view on Meta::CPAN
}
## setup file encoding
if (@opt_icode) {
@opt_icode = map { split /[,\s]+/ } @opt_icode;
if (grep { s/^\+// } @opt_icode) {
unshift @opt_icode, @default_icode_list;
}
@opt_icode = uniq @opt_icode;
if (@opt_icode > 1) {
@opt_icode = grep { !/(?:auto|guess)$/i } @opt_icode;
Encode::Guess->set_suspects(@opt_icode);
$file_code = 'Guess';
}
elsif ($opt_icode[0] =~ /^(?:guess|auto)$/i) {
Encode::Guess->set_suspects(@default_icode_list);
$file_code = 'Guess';
} else {
$file_code = $opt_icode[0];
}
}
else {
$file_code = $default_icode;
}
script/greple view on Meta::CPAN
=over 7
=item B<--icode>=I<code>
Target file is assumed to be encoded in utf8 by default. Use this
option to set specific encoding. When handling Japanese text, you may
choose from 7bit-jis (jis), euc-jp or shiftjis (sjis). Multiple code
can be supplied using multiple option or combined code names with
space or comma, then file encoding is guessed from those code sets.
Use encoding name C<guess> for automatic recognition from default code
list which is euc-jp and 7bit-jis. Following commands are all
equivalent.
greple --icode=guess ...
greple --icode=euc-jp,7bit-jis ...
greple --icode=euc-jp --icode=7bit-jis ...
Default code set are always included suspect code list. If you have
just one code adding to suspect list, put + mark before the code name.
Next example does automatic code detection from euc-kr, ascii, utf8
and UTF-16/32.
greple --icode=+euc-kr ...
t/15_encoding.t view on Meta::CPAN
use open IO => ':utf8';
use lib '.';
use t::Util;
$ENV{NO_COLOR} = 1;
like(run(q(--icode euc-jp ãã㯠t/SAMPLE_euc-jp.txt))->stdout,
qr/ããã¯/, "euc-jp");
like(run(q(--icode guess ãã㯠t/SAMPLE_euc-jp.txt))->stdout,
qr/ããã¯/, "guess euc");
like(run(q(--icode shift-jis ãã㯠t/SAMPLE_sjis.txt))->stdout,
qr/ããã¯/, "shift-jis");
like(run(q(--icode +shift-jis ãã㯠t/SAMPLE_sjis.txt))->stdout,
qr/ããã¯/, "guess shift-jis");
done_testing;
( run in 1.422 second using v1.01-cache-2.11-cpan-7fcb06a456a )