2

約 100K の URL が多数あります。

次のようになります。

blog.example.com/ilovecats/2011/02/10/the-bling-ring/
blog.example.com/fas24
blog.example.com/morg
blog.example.com/whistlermoar/
blog.example.com/punny/
blog.example.com/punny/2012/10/
blog.example.com/punny/2012/10/01/my-mom-is-alien/
blog.example.com/anniesblog/2012/10/12/i- lost-my-iphone
blog.example.com/anniesblog/2012/10/page/3/
blog.example.com/anniesblog/2012/10/page/4
blog.example.com/anniesblog/2012/10/page/ 5
blog.example.com/alfva/
blog.example.com/dudewheresmycar/
blog.example.com/mynameisbilly/
blog.example.com/mynameisbilly/page/23/
blog.example.com/anotherflower/category/axel/
blog .example.com/naxramas/
blog.example.com/angeleoooo/
blog.example.com/angeleoooo/2011/01/01/
blog.example.com/angeleoooo/2011/01/01/happynew-years/

example.com/username/ 以降をすべて削除したいので、残りのリストは次のようになります。

blog.example.com/ilovecats/
blog.example.com/fas24
blog.example.com/morg
blog.example.com/whistlermoar/
blog.example.com/punny/
blog.example.com/anniesblog/
blog.example. com/alfva/
blog.example.com/dudewheresmycar/
blog.example.com/mynameisbilly/
blog.example.com/anotherflower/
blog.example.com/naxramas/
blog.example.com/angeleoooo/

正規表現がこれを行う方法だと聞いたので、これについて数時間ググってみましたが、もうすぐ時間がなくなります。

誰かが私を助けることができますか?

(メモ帳++をインストールしました)

4

2 に答える 2

2

以下を使用できます。

(blog.example.com/\w+\/?).*

これを検索に入れて、検索モードで「正規表現」を選択してください。

置換で、次のように入力します。

\1

そして全部交換。

于 2013-06-28T12:11:59.010 に答える
0

検索する正規表現は次のとおりです。

^([.\w]+\/\w+\/?).*

交換品はこちら。

 \1

分解してみましょう。正規表現は、慎重に分解しない限り、モデムに向かって口笛を吹いているように見えます。

^        only match strings starting at the beginning of a line.
(        begin gathering a bunch of stuff so we can replace it with \1
   [.\w]+   accept a sequence of either dots or characters that appear in words
   \/       accept a / 
   \w+      accept a sequence of characters that can appear in words
   \/?      accept a /, optionally (hence the ?)
)        the end of the parenthesis started above
.*       accept the rest of the string.

+ 文字は 1 つ以上の文字に一致するため、繰り返しに + 文字を使用していることに注意してください。* を使用することもできましたが、正規表現の最後の項目で使用しました。これは、0 回以上の繰り返しに一致します。

于 2013-06-28T12:22:29.937 に答える