Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/400.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 匹配域中除查询外的所有URL_Java_Regex_Pattern Matching - Fatal编程技术网

Java 匹配域中除查询外的所有URL

Java 匹配域中除查询外的所有URL,java,regex,pattern-matching,Java,Regex,Pattern Matching,我希望匹配(java正则表达式)属于某个域的所有URL,除了看起来像查询字符串的URL 例如,我希望匹配 http://www.thehindu.com/arts/music/marrying-keys-to-chips/article4061904.ece 但避免 http://www.thehindu.com/arts/music?article=23417 我尝试了以下方法,但它允许上述两种模式 +^http://www\.thehindu\.com([^\?=])* 那怎么办 if

我希望匹配(java正则表达式)属于某个域的所有URL,除了看起来像查询字符串的URL

例如,我希望匹配

http://www.thehindu.com/arts/music/marrying-keys-to-chips/article4061904.ece
但避免

http://www.thehindu.com/arts/music?article=23417
我尝试了以下方法,但它允许上述两种模式

+^http://www\.thehindu\.com([^\?=])*
那怎么办

if (yourString.matches("(http://)?www\\.thehindu\\.com[^\\?=]*") {
    // match --> doesn't look like a query
} else {
    // no match --> looks like a query or completely different url
}
那怎么办

if (yourString.matches("(http://)?www\\.thehindu\\.com[^\\?=]*") {
    // match --> doesn't look like a query
} else {
    // no match --> looks like a query or completely different url
}

我想不需要regexp,请尝试查找问号

我想不需要regexp,请尝试查找问号
尝试以下操作:

(^|\s)http:\/\/www\.thehindu\.com([^\?])*(\s|$)
其中(^ |\s)和(\s |$)是URL之间的分隔符。如果需要,可以添加更多内容。

尝试以下操作:

(^|\s)http:\/\/www\.thehindu\.com([^\?])*(\s|$)

其中(^ |\s)和(\s |$)是URL之间的分隔符。如果需要,可以添加更多内容。

请详细说明,我无法理解你想说什么。请详细说明,我无法理解你想说什么。这似乎适用于
匹配()。我想没有必要提前看,我有个限制。不能按程序处理这些问题。你这是什么意思?我的答案对您是否足够?这似乎适用于
匹配()。我想没有必要提前看,我有个限制。不能按程序处理这些问题。你这是什么意思?我的回答对你是否足够?