Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.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
Regex 有效正则表达式_Regex - Fatal编程技术网

Regex 有效正则表达式

Regex 有效正则表达式,regex,Regex,好的,我有这根绳子 String line = "6!.242.88.10 - - [07/Mar/2004:16:05:49 -0800] \"GET /twiki/bin/edit/Main/Double_bounce_sender? topicparent=Main.ConfigurationVariables HTTP/1.1\" 401 12846"; 我还有一个java正则表达式 Pattern c = Pattern.compile("(\\s+\\/+)(?<

好的,我有这根绳子

String line = "6!.242.88.10 - - [07/Mar/2004:16:05:49 -0800] \"GET      
/twiki/bin/edit/Main/Double_bounce_sender? 
topicparent=Main.ConfigurationVariables HTTP/1.1\" 401 12846";
我还有一个java正则表达式

Pattern c = Pattern.compile("(\\s+\\/+)(?<=\\/).*(?=)");

Pattern c=Pattern.compile(“(\\s++\\\/+)(?如果您想要一行,可以尝试使用
String.replaceAll

String match = line.replaceAll(".*\\s+(/[^?\\s]*)(?:\\?|\\s).*", "$1");

如果需要一行程序,可以尝试使用
String.replaceAll

String match = line.replaceAll(".*\\s+(/[^?\\s]*)(?:\\?|\\s).*", "$1");

我不能直接把GET放进去,因为它应该是数学的,可能有POST这个词,或者其他任何东西。我只是想让它匹配这个/twiki/bin/edit/Main/Double\u bounce\u sender?或者这个/twiki/bin/edit/Main/Double\u bounce\u senderI再次更新了我的正则表达式。底线是,如果你想t编写一个健壮的正则表达式。但是我需要这个/twiki/bin/edit/Main/Double\u bounce\u发送器(空格或?可以跟在后面)我不能直接把GET放进去,因为它应该是数学的,可能有POST这个词,或者其他任何东西。我只是想让它匹配这个/twiki/bin/edit/Main/Double\u bounce\u sender?或者这个/twiki/bin/edit/Main/Double\u bounce\u senderI再次更新了我的正则表达式。底线是,如果你想t编写一个健壮的正则表达式。但是我需要这个/twiki/bin/edit/Main/Double\u bounce\u发送器(空格或?可以跟在后面)