48

私は正規表現に少し慣れていないので、*8768、*9875、*2353 などのワイルドカード文字列の複数の行/インスタンスを検索しようとしています。

個別に検索するのではなく、これらのすべてのインスタンスを (1 つのファイル内で) 取得したいと考えています。

どんな助けでも大歓迎です。*8768、*9875などを試しました...

4

3 に答える 3

73

あなたが何を求めているのか理解できれば、それは次のような正規表現です。

^(8768|9875|2353)

これは、行頭のみの 3 セットの数字列と一致します。

于 2014-01-08T20:52:00.460 に答える
43

8768テキスト、9875またはを含む行を取得するには2353、次を使用します。

^.*(8768|9875|2353).*$

その意味:

^                      from the beginning of the line
.*                     get any character except \n (0 or more times)
(8768|9875|2353)       if the line contains the string '8768' OR '9875' OR '2353'
.*                     and get any character except \n (0 or more times)
$                      until the end of the line

リテラル*char が必要な場合は、エスケープする必要があります。

^.*(\*8768|\*9875|\*2353).*$
于 2014-01-08T20:59:23.710 に答える
0

I suggest much better solution. Task in my case: add http://google.com/ path before each record and import multiple fields.

CSV single field value (all images just have filenames, separate by |):
"123.jpg|345.jpg|567.jpg"

Tamper 1st plugin: find and replace by REGEXP: pattern: /([a-zA-Z0-9]*)./ replacement: http://google.com/$1

Tamper 2nd plugin: explode setting: explode by |

In this case you don't need any additinal fields mappings and can use 1 field in CSV

于 2016-03-14T02:55:08.337 に答える