1

私は次のURLを持っています

http://mysite/us/product.aspx
http://mysite/de/support.aspx
http://mysite/spaces/product-space
http://mysite/spaces/product-space/forums/this is my topic
http://mysite/spaces/product-space/forums/here is another topic
http://mysite/spaces/support-zone
http://mysite/spaces/support-zone/forums/yet another topic
http://mysite/spaces/internal
http://mysite/spaces/internal/forums/final topic
http://mysite/support/product/default.aspx

を含まないURLを除外し/forums/*、フォーラムトピックURLのみを残すRegExを使用してクロールルール(これはSharePoint 2010検索関連)を追加したいと思います。

のURLを除外し、他のすべてのURLをそのままに../spaces/space1しておくルールが必要です。../spaces/space2/forums/

つまり、正規表現で識別したい結果は次のとおりです(SharePoint Searchの「除外」ルールで使用されます)。

http://mysite/spaces/product-space
http://mysite/spaces/support-zone
http://mysite/spaces/internal

これらの結果を正規表現と一致させないままにする(したがって、このルールによって除外されない)

http://mysite/us/product.aspx
http://mysite/de/support.aspx
http://mysite/spaces/product-space/forums/this is my topic
http://mysite/spaces/product-space/forums/here is another topic
http://mysite/spaces/support-zone/forums/yet another topic
http://mysite/spaces/internal/forums/final topic
http://mysite/support/product/default.aspx

誰かが私を助けることができますか?私は今朝ずっとこれを見ていました、そして私の頭は傷つき始めています-私はそれを説明することができません、私はただ正規表現構造を得ません。

ありがとう

ケビン

4

2 に答える 2

2

先読みを使用/forum/して、URLにあることを表明できます(存在する場合は一致します)。

^(?=.*/forums/)

または、それが存在しないことを主張するための否定的な先読み:

^(?!.*/forums/)

アップデート:

この正規表現は、「除外」リストにあるURLと一致します。

^(?!.*/forums/).*/spaces/(?:space1|space2)

つまり、負の先読みを使用して含まれているすべてのURLを除外し、またはを含むすべてのURL/forums/と一致します。/spaces/space1/spaces/space2

一部のシステムでは、行全体を一致させる必要がありますが、その場合.*、最後にを追加する必要があります。

^(?!.*/forums/).*/spaces/(?:space1|space2).*
于 2013-03-07T15:34:37.430 に答える
2

...Multi-lineモード(1行に1つのURLを想定)では、これでうまくいきました。

(.*?\/forums\/.*?)$

お役に立てれば

アップデート:

あなたのコメントを考えると、使用するパターンは次のようになります。

.*/spaces/(?!.*/).*

基本的に、その後にある/spaces/がそれ以上ないマッチラインと言い/ます(あなたのコメントであなたの基準が述べられたように)。


@rvalvikの正規表現の提案(これも非常に良い別の方法)を使用すると、答えは次のようになります。

^(?!.*/forums/).*/spaces/.*
于 2013-03-07T15:28:09.653 に答える