2016-10-12 16 views
0

I次の文字列を得た:のみ、特定のドメインに一致

<a href="/web/20120412083942/http://test.com/contact">Contact Us</a> | <a href="/web/20120412083942/https://test.com/privacy-policy">Privacy Policy</a> <br /><br /> 
<a href="/web/20120412083942/http://www.cassandracastanedaphoto.com/index2.php#/home/">Photography by Cassandra Castenada</a></span><!-- Start Shareaholic TopSharingBar Automatic --><!-- End Shareaholic TopSharingBar Automatic --><script src="/web/20120412083942js_/http://www.test.com/wp-content/plugins/tweetmeme/button.js" type="text/javascript"></script> 
<!-- tracker added by Ultimate Google Analytics plugin v1.6.0: /web/20120412083942/http://www.oratransplant.nl/uga --> 

私がしたい試合:

/ウェブ/ 20120412083942/http://test.com

/ウェブ/ 20120412083942/https://test.com

/web/20120412083942js_/http://www.test.com

は基本的にウェブ/ [桁] [潜在的な文字列]/http://test.com

を持っている任意のURLはここで、これまでの私の正規表現です:

((http(s)?:\/\/)?web.archive.org)?\/web\/\d+.*?\/http(s)?:\/\/(www\.)?test\.com 

問題があり、それは全体のセクションに一致します。

/ウェブ/ 20120412083942/http://www.cassandracastanedaphoto.com/index2.php#/home/「>カサンドラCastenadahttpによる写真撮影 ://test.com

ドメインがtest.comで始まっていないのを見て停止する方法を教えてください。

答えて

1

私はこの正規表現パターンで成功しました:

Pattern: /web/[^/]+/http[s]{0,1}://(|www\.)test\.com/?[._a-zA-Z-0-9]+ 

Options:^and $ match at line breaks 

Match the characters “/web/” literally «/web/» 
Match any character that is NOT a “/” «[^/]+» 
    Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+» 
Match the characters “/http” literally «/http» 
Match the character “s” «[s]{0,1}» 
    Between zero and one times, as many times as possible, giving back as needed (greedy) «{0,1}» 
Match the characters “://” literally «://» 
Match the regular expression below and capture its match into backreference number 1 «(|www\.)» 
    Match either the regular expression below (attempting the next alternative only if this one fails) «» 
     Empty alternative effectively makes the group optional (following alternatives will be tried if the regex backtracks into the group) «|» 
    Or match regular expression number 2 below (the entire group fails if this one fails to match) «www\.» 
     Match the characters “www” literally «www» 
     Match the character “.” literally «\.» 
Match the characters “test” literally «test» 
Match the character “.” literally «\.» 
Match the characters “com” literally «com» 
Match the character “/” literally «/?» 
    Between zero and one times, as many times as possible, giving back as needed (greedy) «?» 
Match a single character present in the list below «[._a-zA-Z-0-9]+» 
    Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+» 
    One of the characters “._” «._» 
    A character in the range between “a” and “z” «a-z» 
    A character in the range between “A” and “Z” «A-Z» 
    The character “-” «-» 
    A character in the range between “0” and “9” «0-9» 
+0

誰かが、これは素晴らしいですおっと輸出が:) –

+0

何であるか疑問に思うようRegexBuddyソフトウェアを使用してテスト!完璧に動作します! ありがとうございます:) –

関連する問題